Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

"undefined method `route_instance_path' for nil:NilClass" when creating a comment #708

Closed
henrikhodne opened this Issue Nov 1, 2011 · 21 comments

Comments

Projects
None yet
Contributor

henrikhodne commented Nov 1, 2011

Hi,

When I create an admin comment, I get the following error:

undefined method `route_instance_path' for nil:NilClass

I'm using ActiveAdmin 0.3.3 and Rails 3.1.1. The full trace is available here. This may be related to issue #528.

Contributor

spacecowb0y commented Nov 2, 2011

I have the same problem.

I have the same problem.

Just ran into this too.

I'm hitting this same issue with rails 3.1.1 and the latest activeadmin from github. I threw a debugger into the offending code in lib/active_admin/comments.rb and noticed something a bit strange here (line 46):

resource_config = active_admin_config.namespace.resource_for(comment.resource.class)

Trying to just inspect active_admin_config.namespace hangs forever. And obviously the resource_for call just returns nil. If I get some more time I'll investigate further.

kostia commented Nov 9, 2011

Same issue :-(

Same here.

Ruby 1.9.2, Rails 3.1.1, ActiveAdmin 0.3.3

+1 :: 1.9.2p290, 3.1.1, 0.3.4

NoMethodError in Admin::CommentsController#show

undefined method `route_instance_path' for nil:NilClass
activesupport (3.1.1) lib/active_support/whiny_nil.rb:48:in `method_missing'
activeadmin (0.3.4) lib/active_admin/comments.rb:47:in `block (3 levels) in <top (required)>'
activesupport (3.1.1) lib/active_support/callbacks.rb:457:in `_run__4295348987191613425__process_action__2206591857616638567__callbacks'
activesupport (3.1.1) lib/active_support/callbacks.rb:386:in `_run_process_action_callbacks'
activesupport (3.1.1) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.1.1) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.1.1) lib/action_controller/metal/rescue.rb:17:in `process_action'
actionpack (3.1.1) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
activesupport (3.1.1) lib/active_support/notifications.rb:53:in `block in instrument'
activesupport (3.1.1) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (3.1.1) lib/active_support/notifications.rb:53:in `instrument'
actionpack (3.1.1) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (3.1.1) lib/action_controller/metal/params_wrapper.rb:201:in `process_action'
activerecord (3.1.1) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (3.1.1) lib/abstract_controller/base.rb:121:in `process'
actionpack (3.1.1) lib/abstract_controller/rendering.rb:45:in `process'
actionpack (3.1.1) lib/action_controller/metal.rb:193:in `dispatch'
actionpack (3.1.1) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.1.1) lib/action_controller/metal.rb:236:in `block in action'
actionpack (3.1.1) lib/action_dispatch/routing/route_set.rb:65:in `call'
actionpack (3.1.1) lib/action_dispatch/routing/route_set.rb:65:in `dispatch'
actionpack (3.1.1) lib/action_dispatch/routing/route_set.rb:29:in `call'
rack-mount (0.8.3) lib/rack/mount/route_set.rb:152:in `block in call'
rack-mount (0.8.3) lib/rack/mount/code_generation.rb:96:in `block in recognize'
rack-mount (0.8.3) lib/rack/mount/code_generation.rb:103:in `optimized_each'
rack-mount (0.8.3) lib/rack/mount/code_generation.rb:95:in `recognize'
rack-mount (0.8.3) lib/rack/mount/route_set.rb:141:in `call'
actionpack (3.1.1) lib/action_dispatch/routing/route_set.rb:532:in `call'
sass (3.1.10) lib/sass/plugin/rack.rb:54:in `call'
warden (1.1.0) lib/warden/manager.rb:35:in `block in call'
warden (1.1.0) lib/warden/manager.rb:34:in `catch'
warden (1.1.0) lib/warden/manager.rb:34:in `call'
actionpack (3.1.1) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
rack (1.3.5) lib/rack/etag.rb:23:in `call'
rack (1.3.5) lib/rack/conditionalget.rb:25:in `call'
actionpack (3.1.1) lib/action_dispatch/middleware/head.rb:14:in `call'
actionpack (3.1.1) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.1.1) lib/action_dispatch/middleware/flash.rb:243:in `call'
rack (1.3.5) lib/rack/session/abstract/id.rb:195:in `context'
rack (1.3.5) lib/rack/session/abstract/id.rb:190:in `call'
actionpack (3.1.1) lib/action_dispatch/middleware/cookies.rb:331:in `call'
activerecord (3.1.1) lib/active_record/query_cache.rb:62:in `call'
activerecord (3.1.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:477:in `call'
actionpack (3.1.1) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (3.1.1) lib/active_support/callbacks.rb:392:in `_run_call_callbacks'
activesupport (3.1.1) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.1.1) lib/action_dispatch/middleware/callbacks.rb:28:in `call'
actionpack (3.1.1) lib/action_dispatch/middleware/reloader.rb:68:in `call'
rack (1.3.5) lib/rack/sendfile.rb:101:in `call'
actionpack (3.1.1) lib/action_dispatch/middleware/remote_ip.rb:48:in `call'
actionpack (3.1.1) lib/action_dispatch/middleware/show_exceptions.rb:47:in `call'
railties (3.1.1) lib/rails/rack/logger.rb:13:in `call'
rack (1.3.5) lib/rack/methodoverride.rb:24:in `call'
rack (1.3.5) lib/rack/runtime.rb:17:in `call'
activesupport (3.1.1) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.3.5) lib/rack/lock.rb:15:in `call'
actionpack (3.1.1) lib/action_dispatch/middleware/static.rb:53:in `call'
railties (3.1.1) lib/rails/engine.rb:456:in `call'
railties (3.1.1) lib/rails/rack/content_length.rb:16:in `call'
railties (3.1.1) lib/rails/rack/log_tailer.rb:14:in `call'
rack (1.3.5) lib/rack/handler/webrick.rb:59:in `service'

simonc commented Nov 18, 2011

I inspected the code and it seems that the problem is located in lib/active_admin/namespace.rb
When processing the following line :

actual = resources.values.find{|config| config.resource == klass }

Even when config.resource and klass have the same name, their object_id are different.
Is there a duplication somewhere ?
Maybe a workaround could be to compare on string versions of the class names or something like that.

What do you think ?

@simonc It might be hacky, but pry it and/or debug print both values and class types?

Contributor

spacecowb0y commented Nov 19, 2011

Ok, this is a quick fix: https://gist.github.com/1369085 of course this isn't the solution but it works. Please don't judge me!

Contributor

spacecowb0y commented Nov 30, 2011

I think this issue has been fixed with this commit :)

Contributor

gregbell commented Nov 30, 2011

This should be fixed now. I'm going to close it, but please reopen if the issue persists. (Fix is on master)

@gregbell gregbell closed this Nov 30, 2011

Contributor

spacecowb0y commented Nov 30, 2011

@gregbell you rock!

Contributor

gregbell commented Nov 30, 2011

Related to #794

Papipo commented Dec 12, 2011

I am having this issue, I just installed activeadmin from master in an existing rails 3.1.3 application.

Contributor

spacecowb0y commented Dec 12, 2011

I'm still having the same problem on nested resources.

dvliman commented Dec 23, 2011

Still having the same problem, using activeadmin (0.3.4) and rails 3.1.3. It shows NoMethodError page but it was able to post the comment if you hit back button on the browser

activesupport (3.1.3) lib/active_support/whiny_nil.rb:48:in method_missing' activeadmin (0.3.4) lib/active_admin/comments.rb:47:inblock (3 levels) in <top (required)>'
activesupport (3.1.3) lib/active_support/callbacks.rb:457:in _run__4191934539891253243__process_action__3760801307854670151__callbacks' activesupport (3.1.3) lib/active_support/callbacks.rb:386:in_run_process_action_callbacks'
activesupport (3.1.3) lib/active_support/callbacks.rb:81:in run_callbacks' actionpack (3.1.3) lib/abstract_controller/callbacks.rb:17:inprocess_action'
actionpack (3.1.3) lib/action_controller/metal/rescue.rb:17:in process_action' actionpack (3.1.3) lib/action_controller/metal/instrumentation.rb:30:inblock in process_action'
activesupport (3.1.3) lib/active_support/notifications.rb:53:in block in instrument' activesupport (3.1.3) lib/active_support/notifications/instrumenter.rb:21:ininstrument'
activesupport (3.1.3) lib/active_support/notifications.rb:53:in instrument' actionpack (3.1.3) lib/action_controller/metal/instrumentation.rb:29:inprocess_action'
actionpack (3.1.3) lib/action_controller/metal/params_wrapper.rb:201:in process_action' activerecord (3.1.3) lib/active_record/railties/controller_runtime.rb:18:inprocess_action'
actionpack (3.1.3) lib/abstract_controller/base.rb:121:in process' actionpack (3.1.3) lib/abstract_controller/rendering.rb:45:inprocess'
actionpack (3.1.3) lib/action_controller/metal.rb:193:in dispatch' actionpack (3.1.3) lib/action_controller/metal/rack_delegation.rb:14:indispatch'
actionpack (3.1.3) lib/action_controller/metal.rb:236:in block in action' actionpack (3.1.3) lib/action_dispatch/routing/route_set.rb:65:incall'
actionpack (3.1.3) lib/action_dispatch/routing/route_set.rb:65:in dispatch' actionpack (3.1.3) lib/action_dispatch/routing/route_set.rb:29:incall'
rack-mount (0.8.3) lib/rack/mount/route_set.rb:152:in block in call' rack-mount (0.8.3) lib/rack/mount/code_generation.rb:96:inblock in recognize'
rack-mount (0.8.3) lib/rack/mount/code_generation.rb:103:in optimized_each' rack-mount (0.8.3) lib/rack/mount/code_generation.rb:95:inrecognize'
rack-mount (0.8.3) lib/rack/mount/route_set.rb:141:in call' actionpack (3.1.3) lib/action_dispatch/routing/route_set.rb:532:incall'
sass (3.1.11) lib/sass/plugin/rack.rb:54:in call' warden (1.1.0) lib/warden/manager.rb:35:inblock in call'
warden (1.1.0) lib/warden/manager.rb:34:in catch' warden (1.1.0) lib/warden/manager.rb:34:incall'
actionpack (3.1.3) lib/action_dispatch/middleware/best_standards_support.rb:17:in call' rack (1.3.5) lib/rack/etag.rb:23:incall'
rack (1.3.5) lib/rack/conditionalget.rb:25:in call' actionpack (3.1.3) lib/action_dispatch/middleware/head.rb:14:incall'
actionpack (3.1.3) lib/action_dispatch/middleware/params_parser.rb:21:in call' actionpack (3.1.3) lib/action_dispatch/middleware/flash.rb:247:incall'
rack (1.3.5) lib/rack/session/abstract/id.rb:195:in context' rack (1.3.5) lib/rack/session/abstract/id.rb:190:incall'
actionpack (3.1.3) lib/action_dispatch/middleware/cookies.rb:331:in call' activerecord (3.1.3) lib/active_record/query_cache.rb:64:incall'
activerecord (3.1.3) lib/active_record/connection_adapters/abstract/connection_pool.rb:477:in call' actionpack (3.1.3) lib/action_dispatch/middleware/callbacks.rb:29:inblock in call'
activesupport (3.1.3) lib/active_support/callbacks.rb:392:in _run_call_callbacks' activesupport (3.1.3) lib/active_support/callbacks.rb:81:inrun_callbacks'
actionpack (3.1.3) lib/action_dispatch/middleware/callbacks.rb:28:in call' actionpack (3.1.3) lib/action_dispatch/middleware/reloader.rb:68:incall'
rack (1.3.5) lib/rack/sendfile.rb:101:in call' actionpack (3.1.3) lib/action_dispatch/middleware/remote_ip.rb:48:incall'
actionpack (3.1.3) lib/action_dispatch/middleware/show_exceptions.rb:47:in call' railties (3.1.3) lib/rails/rack/logger.rb:13:incall'
rack (1.3.5) lib/rack/methodoverride.rb:24:in call' rack (1.3.5) lib/rack/runtime.rb:17:incall'
activesupport (3.1.3) lib/active_support/cache/strategy/local_cache.rb:72:in call' rack (1.3.5) lib/rack/lock.rb:15:incall'
actionpack (3.1.3) lib/action_dispatch/middleware/static.rb:53:in call' railties (3.1.3) lib/rails/engine.rb:456:incall'
rack (1.3.5) lib/rack/content_length.rb:14:in call' railties (3.1.3) lib/rails/rack/log_tailer.rb:14:incall'
rack (1.3.5) lib/rack/handler/webrick.rb:59:in service' /Users/dv/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/httpserver.rb:111:inservice'
/Users/dv/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/httpserver.rb:70:in run' /Users/dv/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/server.rb:183:inblock in start_thread'

jfedick commented Dec 30, 2011

I'm having the same problem as @dvliman

waseem commented Jan 11, 2012

I'm getting this issue on 0.3.4. Perhaps this should be merged in 0.3.x stable branch and made a point release.

In my controller spec I have this error I don t know if it is related ..

Admin::EmployeesController POST create with invalid params re-renders the 'new' template
Failure/Error: post :create, :employee => {}
NoMethodError:
undefined method `employees_url' for #Admin::EmployeesController:0x007f87810c5c00

Solved this by updating activeadmin. I had activeadmin (0.3.4). Updated my gemfile to use gem 'activeadmin', "~> 0.4.1"

When did "gem install activeadmin" by itself, it installs 0.4.1, but when I add just 'activeadmin' to my gemfile it uses 0.3.4.. not sure why I have to specify.

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