Skip to content

Instantly share code, notes, and snippets.

@richardroyal
Created November 19, 2013 18:58
Show Gist options
  • Save richardroyal/7550560 to your computer and use it in GitHub Desktop.
Save richardroyal/7550560 to your computer and use it in GitHub Desktop.
Bug involving ActiveAdmin, MetaSearch, ActiveUUID (Rails 3.2, Ruby 1.9.3)

rotation.rb

class Rotation < ActiveRecord::Base
  include ActiveUUID::UUID

  has_one :background_check
.
.
.
end

background_check.rb

class BackgroundCheck < ActiveRecord::Base
  include ActiveUUID::UUID

  # Associations
  belongs_to :user
  #natural_key :rotation_id, :received_at
  belongs_to :rotation
.
.
.
end

ActiveAdmin background_checks.rb

ActiveAdmin.register BackgroundCheck do

end
~             

Error when loading /admin/background_checks

Started GET "/admin/background_checks" for 127.0.0.1 at 2013-11-19 13:58:23 -0500
Processing by Admin::BackgroundChecksController#index as HTML
  User Load (0.1ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 LIMIT 1
   (0.4ms)  SELECT COUNT(count_column) FROM (SELECT 1 AS count_column FROM `background_checks` LIMIT 30 OFFSET 0) subquery_for_count 
  User Load (0.3ms)  SELECT `users`.* FROM `users` 
  Rotation Load (0.3ms)  SELECT `rotations`.* FROM `rotations` 
  BackgroundCheck Load (0.3ms)  SELECT `background_checks`.* FROM `background_checks` ORDER BY `background_checks`.`id` desc
  Rendered /home/rroyal/.rvm/gems/ruby-1.9.3-p194@floyd_student_manager/gems/activeadmin-0.6.0/app/views/active_admin/resource/index.html.arb (382.1ms)
Completed 500 Internal Server Error in 395ms

NoMethodError - undefined method `rotation_id_eq' for #<MetaSearch::Searches::BackgroundCheck:0x000000055ae808>:
  meta_search (1.1.3) lib/meta_search/builder.rb:136:in `method_missing'
  actionpack (3.2.14) lib/action_view/helpers/form_helper.rb:1152:in `value'
  actionpack (3.2.14) lib/action_view/helpers/form_helper.rb:1143:in `value'
  actionpack (3.2.14) lib/action_view/helpers/form_options_helper.rb:580:in `to_select_tag'
  actionpack (3.2.14) lib/action_view/helpers/form_options_helper.rb:157:in `select'
  actionpack (3.2.14) lib/action_view/helpers/form_options_helper.rb:642:in `select'
  formtastic (2.2.1) lib/formtastic/inputs/select_input.rb:154:in `select_html'
  formtastic (2.2.1) lib/formtastic/inputs/select_input.rb:149:in `block in to_html'
  actionpack (3.2.14) lib/action_view/helpers/capture_helper.rb:40:in `block in capture'
  actionpack (3.2.14) lib/action_view/helpers/capture_helper.rb:187:in `with_output_buffer'
  haml (4.0.3) lib/haml/helpers/action_view_xss_mods.rb:5:in `with_output_buffer_with_haml_xss'
  actionpack (3.2.14) lib/action_view/helpers/capture_helper.rb:40:in `capture'
  haml (4.0.3) lib/haml/helpers/action_view_mods.rb:59:in `capture_with_haml'
  activeadmin (0.6.0) lib/active_admin/inputs/filter_base.rb:8:in `input_wrapping'
  formtastic (2.2.1) lib/formtastic/inputs/select_input.rb:146:in `to_html'
  formtastic (2.2.1) lib/formtastic/helpers/input_helper.rb:240:in `input'
  activeadmin (0.6.0) lib/active_admin/form_builder.rb:19:in `block in input'
  activeadmin (0.6.0) lib/active_admin/form_builder.rb:166:in `with_new_form_buffer'
  activeadmin (0.6.0) lib/active_admin/form_builder.rb:19:in `input'
  activeadmin (0.6.0) lib/active_admin/filters/forms.rb:11:in `filter'
  activeadmin (0.6.0) lib/active_admin/filters/forms.rb:80:in `block (2 levels) in active_admin_filters_form_for'
  activeadmin (0.6.0) lib/active_admin/filters/forms.rb:75:in `block in active_admin_filters_form_for'
  actionpack (3.2.14) lib/action_view/helpers/capture_helper.rb:40:in `block in capture'
  actionpack (3.2.14) lib/action_view/helpers/capture_helper.rb:187:in `with_output_buffer'
  haml (4.0.3) lib/haml/helpers/action_view_xss_mods.rb:5:in `with_output_buffer_with_haml_xss'
  actionpack (3.2.14) lib/action_view/helpers/capture_helper.rb:40:in `capture'
  haml (4.0.3) lib/haml/helpers/action_view_mods.rb:59:in `capture_with_haml'
  actionpack (3.2.14) lib/action_view/helpers/form_helper.rb:378:in `form_for'
  haml (4.0.3) lib/haml/helpers/action_view_mods.rb:146:in `form_for_with_haml'
  haml (4.0.3) lib/haml/helpers/action_view_xss_mods.rb:28:in `form_for_with_haml_xss'
  activeadmin (0.6.0) lib/active_admin/filters/forms.rb:74:in `active_admin_filters_form_for'
  arbre (1.0.1) lib/arbre/element.rb:175:in `method_missing'
  activeadmin (0.6.0) lib/active_admin/filters/resource_extension.rb:120:in `block in filters_sidebar_section'
  activeadmin (0.6.0) lib/active_admin/views/components/sidebar_section.rb:19:in `build_sidebar_content'
  activeadmin (0.6.0) lib/active_admin/views/components/sidebar_section.rb:12:in `build'
  arbre (1.0.1) lib/arbre/element/builder_methods.rb:30:in `block in build_tag'
  arbre (1.0.1) lib/arbre/context.rb:92:in `with_current_arbre_element'
  arbre (1.0.1) lib/arbre/element/builder_methods.rb:49:in `with_current_arbre_element'
  arbre (1.0.1) lib/arbre/element/builder_methods.rb:26:in `build_tag'
  arbre (1.0.1) lib/arbre/element/builder_methods.rb:39:in `insert_tag'
  arbre (1.0.1) lib/arbre/element/builder_methods.rb:18:in `sidebar_section'
  activeadmin (0.6.0) lib/active_admin/views/pages/base.rb:117:in `block (2 levels) in build_sidebar'
  activeadmin (0.6.0) lib/active_admin/views/pages/base.rb:116:in `block in build_sidebar'
  arbre (1.0.1) lib/arbre/element/builder_methods.rb:31:in `block in build_tag'
  arbre (1.0.1) lib/arbre/context.rb:92:in `with_current_arbre_element'
  arbre (1.0.1) lib/arbre/element/builder_methods.rb:49:in `with_current_arbre_element'
  arbre (1.0.1) lib/arbre/element/builder_methods.rb:26:in `build_tag'
  arbre (1.0.1) lib/arbre/element/builder_methods.rb:39:in `insert_tag'
  arbre (1.0.1) lib/arbre/element/builder_methods.rb:18:in `div'
  activeadmin (0.6.0) lib/active_admin/views/pages/base.rb:115:in `build_sidebar'
  activeadmin (0.6.0) lib/active_admin/views/pages/base.rb:61:in `block in build_page_content'
  arbre (1.0.1) lib/arbre/element/builder_methods.rb:31:in `block in build_tag'
  arbre (1.0.1) lib/arbre/context.rb:92:in `with_current_arbre_element'
  arbre (1.0.1) lib/arbre/element/builder_methods.rb:49:in `with_current_arbre_element'
  arbre (1.0.1) lib/arbre/element/builder_methods.rb:26:in `build_tag'
  arbre (1.0.1) lib/arbre/element/builder_methods.rb:39:in `insert_tag'
  arbre (1.0.1) lib/arbre/element/builder_methods.rb:18:in `div'
  activeadmin (0.6.0) lib/active_admin/views/pages/base.rb:59:in `build_page_content'
  activeadmin (0.6.0) lib/active_admin/views/pages/base.rb:42:in `block (2 levels) in build_page'
  arbre (1.0.1) lib/arbre/element/builder_methods.rb:31:in `block in build_tag'
  arbre (1.0.1) lib/arbre/context.rb:92:in `with_current_arbre_element'
  arbre (1.0.1) lib/arbre/element/builder_methods.rb:49:in `with_current_arbre_element'
  arbre (1.0.1) lib/arbre/element/builder_methods.rb:26:in `build_tag'
  arbre (1.0.1) lib/arbre/element/builder_methods.rb:39:in `insert_tag'
  arbre (1.0.1) lib/arbre/element/builder_methods.rb:18:in `div'
  activeadmin (0.6.0) lib/active_admin/views/pages/base.rb:39:in `block in build_page'
  arbre (1.0.1) lib/arbre/context.rb:92:in `with_current_arbre_element'
  arbre (1.0.1) lib/arbre/element/builder_methods.rb:49:in `with_current_arbre_element'
  activeadmin (0.6.0) lib/active_admin/views/pages/base.rb:38:in `build_page'
  activeadmin (0.6.0) lib/active_admin/views/pages/base.rb:10:in `build'
  arbre (1.0.1) lib/arbre/element/builder_methods.rb:30:in `block in build_tag'
  arbre (1.0.1) lib/arbre/context.rb:92:in `with_current_arbre_element'
  arbre (1.0.1) lib/arbre/element/builder_methods.rb:26:in `build_tag'
  arbre (1.0.1) lib/arbre/element/builder_methods.rb:39:in `insert_tag'
  activeadmin (0.6.0) app/views/active_admin/resource/index.html.arb:1:in `block in __home_rroyal__rvm_gems_ruby_______p____floyd_student_manager_gems_activeadmin_______app_views_active_admin_resource_index_html_arb__357800854967969933_44019520'
  arbre (1.0.1) lib/arbre/context.rb:45:in `initialize'
  activeadmin (0.6.0) app/views/active_admin/resource/index.html.arb:1:in `__home_rroyal__rvm_gems_ruby_______p____floyd_student_manager_gems_activeadmin_______app_views_active_admin_resource_index_html_arb__357800854967969933_44019520'
  actionpack (3.2.14) lib/action_view/template.rb:145:in `block in render'
  activesupport (3.2.14) lib/active_support/notifications.rb:125:in `instrument'
  actionpack (3.2.14) lib/action_view/template.rb:143:in `render'
  actionpack (3.2.14) lib/action_view/renderer/template_renderer.rb:48:in `block (2 levels) in render_template'
  actionpack (3.2.14) lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument'
  activesupport (3.2.14) lib/active_support/notifications.rb:123:in `block in instrument'
  activesupport (3.2.14) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  activesupport (3.2.14) lib/active_support/notifications.rb:123:in `instrument'
  actionpack (3.2.14) lib/action_view/renderer/abstract_renderer.rb:38:in `instrument'
  actionpack (3.2.14) lib/action_view/renderer/template_renderer.rb:47:in `block in render_template'
  actionpack (3.2.14) lib/action_view/renderer/template_renderer.rb:55:in `render_with_layout'
  actionpack (3.2.14) lib/action_view/renderer/template_renderer.rb:46:in `render_template'
  actionpack (3.2.14) lib/action_view/renderer/template_renderer.rb:19:in `render'
  actionpack (3.2.14) lib/action_view/renderer/renderer.rb:36:in `render_template'
  actionpack (3.2.14) lib/action_view/renderer/renderer.rb:17:in `render'
  actionpack (3.2.14) lib/abstract_controller/rendering.rb:110:in `_render_template'
  actionpack (3.2.14) lib/action_controller/metal/streaming.rb:225:in `_render_template'
  actionpack (3.2.14) lib/abstract_controller/rendering.rb:103:in `render_to_body'
  actionpack (3.2.14) lib/action_controller/metal/renderers.rb:28:in `render_to_body'
  actionpack (3.2.14) lib/action_controller/metal/compatibility.rb:50:in `render_to_body'
  actionpack (3.2.14) lib/abstract_controller/rendering.rb:88:in `render'
  actionpack (3.2.14) lib/action_controller/metal/rendering.rb:16:in `render'
  actionpack (3.2.14) lib/action_controller/metal/instrumentation.rb:40:in `block (2 levels) in render'
  activesupport (3.2.14) lib/active_support/core_ext/benchmark.rb:5:in `block in ms'
  /home/rroyal/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/benchmark.rb:295:in `realtime'
  activesupport (3.2.14) lib/active_support/core_ext/benchmark.rb:5:in `ms'
  actionpack (3.2.14) lib/action_controller/metal/instrumentation.rb:40:in `block in render'
  actionpack (3.2.14) lib/action_controller/metal/instrumentation.rb:83:in `cleanup_view_runtime'
  activerecord (3.2.14) lib/active_record/railties/controller_runtime.rb:24:in `cleanup_view_runtime'
  actionpack (3.2.14) lib/action_controller/metal/instrumentation.rb:39:in `render'
  activeadmin (0.6.0) lib/active_admin/resource_controller/actions.rb:13:in `block (2 levels) in index'
  actionpack (3.2.14) lib/action_controller/metal/responder.rb:230:in `default_render'
  actionpack (3.2.14) lib/action_controller/metal/responder.rb:160:in `to_html'
  responders (1.0.0.rc) lib/responders/flash_responder.rb:104:in `to_html'
  actionpack (3.2.14) lib/action_controller/metal/responder.rb:153:in `respond'
  actionpack (3.2.14) lib/action_controller/metal/responder.rb:146:in `call'
  actionpack (3.2.14) lib/action_controller/metal/mime_responds.rb:239:in `respond_with'
  inherited_resources (1.4.1) lib/inherited_resources/actions.rb:7:in `index'
  activeadmin (0.6.0) lib/active_admin/resource_controller/actions.rb:11:in `index'
  actionpack (3.2.14) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
  actionpack (3.2.14) lib/abstract_controller/base.rb:167:in `process_action'
  actionpack (3.2.14) lib/action_controller/metal/rendering.rb:10:in `process_action'
  actionpack (3.2.14) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
  activesupport (3.2.14) lib/active_support/callbacks.rb:447:in `_run__2173790311164449794__process_action__1127962124303532105__callbacks'
  activesupport (3.2.14) lib/active_support/callbacks.rb:405:in `__run_callback'
  activesupport (3.2.14) lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
  activesupport (3.2.14) lib/active_support/callbacks.rb:81:in `run_callbacks'
  actionpack (3.2.14) lib/abstract_controller/callbacks.rb:17:in `process_action'
  actionpack (3.2.14) lib/action_controller/metal/rescue.rb:29:in `process_action'
  actionpack (3.2.14) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
  activesupport (3.2.14) lib/active_support/notifications.rb:123:in `block in instrument'
  activesupport (3.2.14) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  activesupport (3.2.14) lib/active_support/notifications.rb:123:in `instrument'
  actionpack (3.2.14) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
  actionpack (3.2.14) lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
  activerecord (3.2.14) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
  actionpack (3.2.14) lib/abstract_controller/base.rb:121:in `process'
  actionpack (3.2.14) lib/abstract_controller/rendering.rb:45:in `process'
  actionpack (3.2.14) lib/action_controller/metal.rb:203:in `dispatch'
  actionpack (3.2.14) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
  actionpack (3.2.14) lib/action_controller/metal.rb:246:in `block in action'
  actionpack (3.2.14) lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
  actionpack (3.2.14) lib/action_dispatch/routing/route_set.rb:36:in `call'
  journey (1.0.4) lib/journey/router.rb:68:in `block in call'
  journey (1.0.4) lib/journey/router.rb:56:in `call'
  actionpack (3.2.14) lib/action_dispatch/routing/route_set.rb:608:in `call'
  warden (1.2.3) lib/warden/manager.rb:35:in `block in call'
  warden (1.2.3) lib/warden/manager.rb:34:in `call'
  actionpack (3.2.14) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
  rack (1.4.5) lib/rack/etag.rb:23:in `call'
  rack (1.4.5) lib/rack/conditionalget.rb:25:in `call'
  actionpack (3.2.14) lib/action_dispatch/middleware/head.rb:14:in `call'
  actionpack (3.2.14) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
  actionpack (3.2.14) lib/action_dispatch/middleware/flash.rb:242:in `call'
  rack (1.4.5) lib/rack/session/abstract/id.rb:210:in `context'
  rack (1.4.5) lib/rack/session/abstract/id.rb:205:in `call'
  actionpack (3.2.14) lib/action_dispatch/middleware/cookies.rb:341:in `call'
  activerecord (3.2.14) lib/active_record/query_cache.rb:64:in `call'
  activerecord (3.2.14) lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call'
  actionpack (3.2.14) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
  activesupport (3.2.14) lib/active_support/callbacks.rb:405:in `_run__482021682661606880__call__3390038772216503756__callbacks'
  activesupport (3.2.14) lib/active_support/callbacks.rb:405:in `__run_callback'
  activesupport (3.2.14) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
  activesupport (3.2.14) lib/active_support/callbacks.rb:81:in `run_callbacks'
  actionpack (3.2.14) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
  actionpack (3.2.14) lib/action_dispatch/middleware/reloader.rb:65:in `call'
  actionpack (3.2.14) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
  better_errors (0.9.0) lib/better_errors/middleware.rb:84:in `protected_app_call'
  better_errors (0.9.0) lib/better_errors/middleware.rb:79:in `better_errors_call'
  better_errors (0.9.0) lib/better_errors/middleware.rb:56:in `call'
  actionpack (3.2.14) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
  actionpack (3.2.14) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
  railties (3.2.14) lib/rails/rack/logger.rb:32:in `call_app'
  railties (3.2.14) lib/rails/rack/logger.rb:16:in `block in call'
  activesupport (3.2.14) lib/active_support/tagged_logging.rb:22:in `tagged'
  railties (3.2.14) lib/rails/rack/logger.rb:16:in `call'
  quiet_assets (1.0.2) lib/quiet_assets.rb:18:in `call_with_quiet_assets'
  actionpack (3.2.14) lib/action_dispatch/middleware/request_id.rb:22:in `call'
  rack (1.4.5) lib/rack/methodoverride.rb:21:in `call'
  rack (1.4.5) lib/rack/runtime.rb:17:in `call'
  activesupport (3.2.14) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
  rack (1.4.5) lib/rack/lock.rb:15:in `call'
  actionpack (3.2.14) lib/action_dispatch/middleware/static.rb:63:in `call'
  railties (3.2.14) lib/rails/engine.rb:484:in `call'
  railties (3.2.14) lib/rails/application.rb:231:in `call'
  rack (1.4.5) lib/rack/content_length.rb:14:in `call'
  railties (3.2.14) lib/rails/rack/log_tailer.rb:17:in `call'
  thin (1.5.1) lib/thin/connection.rb:81:in `block in pre_process'
  thin (1.5.1) lib/thin/connection.rb:79:in `pre_process'
  thin (1.5.1) lib/thin/connection.rb:54:in `process'
  thin (1.5.1) lib/thin/connection.rb:39:in `receive_data'
  eventmachine (1.0.3) lib/eventmachine.rb:187:in `run'
  thin (1.5.1) lib/thin/backends/base.rb:63:in `start'
  thin (1.5.1) lib/thin/server.rb:159:in `start'
  rack (1.4.5) lib/rack/handler/thin.rb:13:in `run'
  rack (1.4.5) lib/rack/server.rb:268:in `start'
  railties (3.2.14) lib/rails/commands/server.rb:70:in `start'
  railties (3.2.14) lib/rails/commands.rb:55:in `block in <top (required)>'
  railties (3.2.14) lib/rails/commands.rb:50:in `<top (required)>'
  script/rails:6:in `<main>'
  script/rails:0:in `<main>'

@richardroyal
Copy link
Author

This error happens when using MySQL but not when using PG.

@richardroyal
Copy link
Author

Worked around with IRC folks:

<zorab47> rroyal: You could try to exclude that filter as a temporary fix. remove_filter :rotation
<rroyal> zorab47: I can try that
<zorab47> I assume you are on ActiveAdmin 0.6.1 or 0.6.2, correct?
<rroyal> That doesn't not solve the problem. 0.6.0 is installed
<rroyal> zorab47: Ok wrong branch. That actually does fix it
<rroyal> zorab47: I think I can make do with that because I don't need that as a filter. But I have an issue on a similarly related model, let me adjust that as well
<zorab47> Could it be related to fields defined as `has_one` ?
<rroyal> What do you mean? I need a Rotation to have one BackgroundCheck and a BGCK belongs to a Rotation
<zorab47> I'm trying to think through potential issues in AA's auto filters.
<rroyal> Yeah, on my other model's issue, there is some problem with a custom filter
<rroyal> Hmm, I switched a filter on an associated model attribute from a stabby lambda to a proc and the other problem is solved. That was a stab in the dark and I have no idea why that worked
<rroyal> I don't need the auto filter on Rotation for the BackgroundCheck view so I think my problems are solved unless there is some deeper issue. 
<seanlinsley> rroyal: what sort of symptom were you getting that the stubby lambda to proc change fixed?
* seanlinsley really wants to set up https://botbot.me
<rroyal> seanlinsley: the view says 'wrong number of arguments (1 for 0)' and better_errors highlights a line:            template.instance_eval(&options[:collection])
<rroyal> activeadmin (0.6.0) lib/active_admin/inputs/filter_base.rb ilne 19
<seanlinsley> yeah that sounds right. that's been an issue for a long time, just haven't gone to the trouble of fixing it
<rroyal> * line 24
<rroyal> Yeah, I see the comment about proc

@richardroyal
Copy link
Author

First bug related to: activeadmin/activeadmin#2382

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment