undefined method `object' for #<Mongoid::Criteria:0x..> #52

Closed
goyox86 opened this Issue Sep 10, 2013 · 10 comments

Comments

Projects
None yet
8 participants

goyox86 commented Sep 10, 2013

Hi I get this when I try to go to any resource/index

ActionView::Template::Error (undefined method `object' for #<Mongoid::Criteria:0x007f948a8bcf10>):
    1: insert_tag renderer_for(:index)
  /Users/goyox86/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/mongoid-38de2e96edc8/lib/mongoid/criteria.rb:501:in `method_missing'
  /Users/goyox86/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/active_admin-ac4918ef99cf/lib/active_admin/filters/formtastic_addons.rb:40:in `klass'
  /Users/goyox86/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/active_admin-ac4918ef99cf/lib/active_admin/filters/formtastic_addons.rb:20:in `reflection_for'
  /Users/goyox86/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/active_admin-ac4918ef99cf/lib/active_admin/filters/forms.rb:26:in `default_input_type'
  /Users/goyox86/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/active_admin-ac4918ef99cf/lib/active_admin/filters/forms.rb:15:in `filter'
  /Users/goyox86/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/active_admin-ac4918ef99cf/lib/active_admin/filters/forms.rb:72:in `block (2 levels) in active_admin_filters_form_for'
  /Users/goyox86/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/active_admin-ac4918ef99cf/lib/active_admin/filters/forms.rb:66:in `each'
  /Users/goyox86/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/active_admin-ac4918ef99cf/lib/active_admin/filters/forms.rb:66:in `block in active_admin_filters_form_for'
  actionpack (4.0.0) lib/action_view/helpers/capture_helper.rb:38:in `block in capture'
  actionpack (4.0.0) lib/action_view/helpers/capture_helper.rb:200:in `with_output_buffer'
  actionpack (4.0.0) lib/action_view/helpers/capture_helper.rb:38:in `capture'
  actionpack (4.0.0) lib/action_view/helpers/form_helper.rb:435:in `form_for'
  /Users/goyox86/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/active_admin-ac4918ef99cf/lib/active_admin/filters/forms.rb:65:in `active_admin_filters_form_for'
  arbre (1.0.1) lib/arbre/element.rb:175:in `method_missing'
  /Users/goyox86/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/active_admin-ac4918ef99cf/lib/active_admin/filters/resource_extension.rb:122:in `block in filters_sidebar_section'
  /Users/goyox86/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/active_admin-ac4918ef99cf/lib/active_admin/views/components/sidebar_section.rb:19:in `instance_eval'
  /Users/goyox86/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/active_admin-ac4918ef99cf/lib/active_admin/views/components/sidebar_section.rb:19:in `build_sidebar_content'
  /Users/goyox86/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/active_admin-ac4918ef99cf/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:14:in `sidebar_section'
  /Users/goyox86/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/active_admin-ac4918ef99cf/lib/active_admin/views/pages/base.rb:122:in `block (2 levels) in build_sidebar'
  /Users/goyox86/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/active_admin-ac4918ef99cf/lib/active_admin/views/pages/base.rb:121:in `collect'
  /Users/goyox86/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/active_admin-ac4918ef99cf/lib/active_admin/views/pages/base.rb:121: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:14:in `div'
  /Users/goyox86/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/active_admin-ac4918ef99cf/lib/active_admin/views/pages/base.rb:120:in `build_sidebar'
  /Users/goyox86/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/active_admin-ac4918ef99cf/lib/active_admin/views/pages/base.rb:66: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:14:in `div'
  /Users/goyox86/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/active_admin-ac4918ef99cf/lib/active_admin/views/pages/base.rb:64:in `build_page_content'
  /Users/goyox86/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/active_admin-ac4918ef99cf/lib/active_admin/views/pages/base.rb:47: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:14:in `div'
  /Users/goyox86/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/active_admin-ac4918ef99cf/lib/active_admin/views/pages/base.rb:44: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'
  /Users/goyox86/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/active_admin-ac4918ef99cf/lib/active_admin/views/pages/base.rb:43:in `build_page'
  /Users/goyox86/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/active_admin-ac4918ef99cf/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'
  /Users/goyox86/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/active_admin-ac4918ef99cf/app/views/active_admin/resource/index.html.arb:1:in `block in ___sers_goyox____rbenv_versions_______p____lib_ruby_gems_______bundler_gems_active_admin_ac____ef__cf_app_views_active_admin_resource_index_html_arb___2443507677352339677_70137946052220'
  arbre (1.0.1) lib/arbre/context.rb:45:in `instance_eval'
  arbre (1.0.1) lib/arbre/context.rb:45:in `initialize'
  /Users/goyox86/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/active_admin-ac4918ef99cf/app/views/active_admin/resource/index.html.arb:1:in `new'
  /Users/goyox86/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/active_admin-ac4918ef99cf/app/views/active_admin/resource/index.html.arb:1:in `___sers_goyox____rbenv_versions_______p____lib_ruby_gems_______bundler_gems_active_admin_ac____ef__cf_app_views_active_admin_resource_index_html_arb___2443507677352339677_70137946052220'
  actionpack (4.0.0) lib/action_view/template.rb:143:in `block in render'
  activesupport (4.0.0) lib/active_support/notifications.rb:161:in `instrument'
  actionpack (4.0.0) lib/action_view/template.rb:141:in `render'
  actionpack (4.0.0) lib/action_view/renderer/template_renderer.rb:49:in `block (2 levels) in render_template'
  actionpack (4.0.0) lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument'
  activesupport (4.0.0) lib/active_support/notifications.rb:159:in `block in instrument'
  activesupport (4.0.0) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  activesupport (4.0.0) lib/active_support/notifications.rb:159:in `instrument'
  actionpack (4.0.0) lib/action_view/renderer/abstract_renderer.rb:38:in `instrument'
  actionpack (4.0.0) lib/action_view/renderer/template_renderer.rb:48:in `block in render_template'
  actionpack (4.0.0) lib/action_view/renderer/template_renderer.rb:56:in `render_with_layout'
  actionpack (4.0.0) lib/action_view/renderer/template_renderer.rb:47:in `render_template'
  actionpack (4.0.0) lib/action_view/renderer/template_renderer.rb:17:in `render'
  actionpack (4.0.0) lib/action_view/renderer/renderer.rb:42:in `render_template'
  actionpack (4.0.0) lib/action_view/renderer/renderer.rb:23:in `render'
  actionpack (4.0.0) lib/abstract_controller/rendering.rb:127:in `_render_template'
  actionpack (4.0.0) lib/action_controller/metal/streaming.rb:219:in `_render_template'
  actionpack (4.0.0) lib/abstract_controller/rendering.rb:120:in `render_to_body'
  actionpack (4.0.0) lib/action_controller/metal/rendering.rb:33:in `render_to_body'
  actionpack (4.0.0) lib/action_controller/metal/renderers.rb:26:in `render_to_body'
  actionpack (4.0.0) lib/abstract_controller/rendering.rb:97:in `render'
  actionpack (4.0.0) lib/action_controller/metal/rendering.rb:16:in `render'
  actionpack (4.0.0) lib/action_controller/metal/instrumentation.rb:41:in `block (2 levels) in render'
  activesupport (4.0.0) lib/active_support/core_ext/benchmark.rb:12:in `block in ms'
  /Users/goyox86/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/benchmark.rb:296:in `realtime'
  activesupport (4.0.0) lib/active_support/core_ext/benchmark.rb:12:in `ms'
  actionpack (4.0.0) lib/action_controller/metal/instrumentation.rb:41:in `block in render'
  actionpack (4.0.0) lib/action_controller/metal/instrumentation.rb:84:in `cleanup_view_runtime'
  actionpack (4.0.0) lib/action_controller/metal/instrumentation.rb:40:in `render'
  /Users/goyox86/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/active_admin-ac4918ef99cf/lib/active_admin/resource_controller/actions.rb:13:in `block (2 levels) in index'
  actionpack (4.0.0) lib/action_controller/metal/responder.rb:231:in `call'
  actionpack (4.0.0) lib/action_controller/metal/responder.rb:231:in `default_render'
  actionpack (4.0.0) lib/action_controller/metal/responder.rb:161:in `to_html'
  responders (1.0.0.rc) lib/responders/flash_responder.rb:104:in `to_html'
  actionpack (4.0.0) lib/action_controller/metal/responder.rb:154:in `respond'
  actionpack (4.0.0) lib/action_controller/metal/responder.rb:147:in `call'
  actionpack (4.0.0) lib/action_controller/metal/mime_responds.rb:330:in `respond_with'
  inherited_resources (1.4.1) lib/inherited_resources/actions.rb:7:in `index'
  /Users/goyox86/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/active_admin-ac4918ef99cf/lib/active_admin/resource_controller/actions.rb:11:in `index'
  actionpack (4.0.0) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
  actionpack (4.0.0) lib/abstract_controller/base.rb:189:in `process_action'
  actionpack (4.0.0) lib/action_controller/metal/rendering.rb:10:in `process_action'
  actionpack (4.0.0) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
  activesupport (4.0.0) lib/active_support/callbacks.rb:413:in `_run__4544908531130560647__process_action__callbacks'
  activesupport (4.0.0) lib/active_support/callbacks.rb:80:in `run_callbacks'
  actionpack (4.0.0) lib/abstract_controller/callbacks.rb:17:in `process_action'
  actionpack (4.0.0) lib/action_controller/metal/rescue.rb:29:in `process_action'
  actionpack (4.0.0) lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
  activesupport (4.0.0) lib/active_support/notifications.rb:159:in `block in instrument'
  activesupport (4.0.0) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  activesupport (4.0.0) lib/active_support/notifications.rb:159:in `instrument'
  actionpack (4.0.0) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
  actionpack (4.0.0) lib/action_controller/metal/params_wrapper.rb:245:in `process_action'
  actionpack (4.0.0) lib/abstract_controller/base.rb:136:in `process'
  actionpack (4.0.0) lib/abstract_controller/rendering.rb:44:in `process'
  actionpack (4.0.0) lib/action_controller/metal.rb:195:in `dispatch'
  actionpack (4.0.0) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
  actionpack (4.0.0) lib/action_controller/metal.rb:231:in `block in action'
  actionpack (4.0.0) lib/action_dispatch/routing/route_set.rb:80:in `call'
  actionpack (4.0.0) lib/action_dispatch/routing/route_set.rb:80:in `dispatch'
  actionpack (4.0.0) lib/action_dispatch/routing/route_set.rb:48:in `call'
  actionpack (4.0.0) lib/action_dispatch/journey/router.rb:71:in `block in call'
  actionpack (4.0.0) lib/action_dispatch/journey/router.rb:59:in `each'
  actionpack (4.0.0) lib/action_dispatch/journey/router.rb:59:in `call'
  actionpack (4.0.0) lib/action_dispatch/routing/route_set.rb:655:in `call'
  /Users/goyox86/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/mongoid-38de2e96edc8/lib/rack/mongoid/middleware/identity_map.rb:34:in `block in call'
  /Users/goyox86/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/mongoid-38de2e96edc8/lib/mongoid/unit_of_work.rb:39:in `unit_of_work'
  /Users/goyox86/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/mongoid-38de2e96edc8/lib/rack/mongoid/middleware/identity_map.rb:34:in `call'
  rack-cors (0.2.8) lib/rack/cors.rb:54: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 `catch'
  warden (1.2.3) lib/warden/manager.rb:34:in `call'
  rack (1.5.2) lib/rack/etag.rb:23:in `call'
  rack (1.5.2) lib/rack/conditionalget.rb:25:in `call'
  rack (1.5.2) lib/rack/head.rb:11:in `call'
  actionpack (4.0.0) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
  actionpack (4.0.0) lib/action_dispatch/middleware/flash.rb:241:in `call'
  rack (1.5.2) lib/rack/session/abstract/id.rb:225:in `context'
  rack (1.5.2) lib/rack/session/abstract/id.rb:220:in `call'
  actionpack (4.0.0) lib/action_dispatch/middleware/cookies.rb:486:in `call'
  actionpack (4.0.0) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
  activesupport (4.0.0) lib/active_support/callbacks.rb:373:in `_run__4556293363330684592__call__callbacks'
  activesupport (4.0.0) lib/active_support/callbacks.rb:80:in `run_callbacks'
  actionpack (4.0.0) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
  actionpack (4.0.0) lib/action_dispatch/middleware/reloader.rb:64:in `call'
  actionpack (4.0.0) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
  actionpack (4.0.0) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
  actionpack (4.0.0) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
  railties (4.0.0) lib/rails/rack/logger.rb:38:in `call_app'
  railties (4.0.0) lib/rails/rack/logger.rb:21:in `block in call'
  activesupport (4.0.0) lib/active_support/tagged_logging.rb:67:in `block in tagged'
  activesupport (4.0.0) lib/active_support/tagged_logging.rb:25:in `tagged'
  activesupport (4.0.0) lib/active_support/tagged_logging.rb:67:in `tagged'
  railties (4.0.0) lib/rails/rack/logger.rb:21:in `call'
  actionpack (4.0.0) lib/action_dispatch/middleware/request_id.rb:21:in `call'
  rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'
  rack (1.5.2) lib/rack/runtime.rb:17:in `call'
  activesupport (4.0.0) lib/active_support/cache/strategy/local_cache.rb:83:in `call'
  rack (1.5.2) lib/rack/lock.rb:17:in `call'
  actionpack (4.0.0) lib/action_dispatch/middleware/static.rb:64:in `call'
  railties (4.0.0) lib/rails/engine.rb:511:in `call'
  railties (4.0.0) lib/rails/application.rb:97:in `call'
  rack (1.5.2) lib/rack/content_length.rb:14: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 `catch'
  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_machine'
  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.5.2) lib/rack/handler/thin.rb:16:in `run'
  rack (1.5.2) lib/rack/server.rb:264:in `start'
  railties (4.0.0) lib/rails/commands/server.rb:84:in `start'
  railties (4.0.0) lib/rails/commands.rb:78:in `block in <top (required)>'
  railties (4.0.0) lib/rails/commands.rb:73:in `tap'
  railties (4.0.0) lib/rails/commands.rb:73:in `<top (required)>'
  bin/rails:4:in `require'
  bin/rails:4:in `<main>'

My gemfile looks like this

source 'https://rubygems.org'

ruby '2.0.0'

gem 'active_model_serializers'
gem 'activeadmin', github: 'gregbell/active_admin', branch: 'rails4'
gem 'activeadmin-mongoid', github: 'DanielePalombo/activeadmin-mongoid'
gem 'aws-sdk', '~> 1.3.4'
gem 'devise', github: 'plataformatec/devise'
gem 'doorkeeper'
gem 'foreman'
gem 'formtastic', github: 'justinfrench/formtastic'
gem 'mongoid', github: 'mongoid'
gem 'mongoid-tree', require: 'mongoid/tree'
gem 'mongoid-paperclip', require: 'mongoid_paperclip'
gem 'pry-rails'
gem 'puma'
gem 'rack-cors', require: 'rack/cors'
gem 'rails', '4.0.0'
gem 'state_machine'

I've been trying to track down the bug without success, does anyone have experienced something similar?

Member

elia commented Oct 5, 2013

@goyox86 hey, I'm getting this error too on the rails4 branch. Found any solution?

Funfun commented Oct 30, 2013

i'v got the same with rails 4.0.0

Funfun commented Oct 30, 2013

Avoid problem but not resolve

https://gist.github.com/Funfun/7233649

I am also getting this on the rails4 branch.

+1 on the rails 4 branch

Funfun's solution worked for me. Inserted fix.rb into the config/initializers directory, and I stopped getting the error. Thanks!

We ran into the same issue. Putting fix.rb into config/initializers also "avoided" the problem for us.

The side effect is it removes search filter sidebar on index pages, which is quite unfortunate as we actually do use the filter sidebar.

This seems to be caused by ActiveAdmin moving from meta_search to ransack, which doesn't play with mongoid very well. Over at ActiveAdmin they are talking about supporting this gregbell/active_admin#2714.

I am not too sure what exactly needs to be done to fully fix the filter search sidebar. It would be great to see this working

blotto commented Aug 29, 2014

I have a mix of AR and Mongo Models so Funfun's solution is too broad for every index page. Instead, on those AA pages that register a Mongo Model .. somewhat useful despite no filters :/

  controller do
     before_filter only: :index do
       active_admin_config.filters  = false
     end
  end

@goyox86 goyox86 closed this Aug 17, 2016

costa commented Mar 5, 2017

@goyox86 any particular reason for closing this issue?

goyox86 commented Mar 6, 2017

I have no reasons to maintain this opened @costa. Feel free to close it. Thanks!

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