Repository: activeadmin/activeadmin

Issue #2518: belongs_to and undefined method `find' for nil:NilClass
Created: 2013-09-30T14:29:47Z
I've a HotelPicture model belongs_to a Hotel model.

ActiveAdmin.register HotelPicture do
  config.comments = false
  menu :parent => "Hotels"

  belongs_to :hotel
end

If I check routes I've :
batch_action_admin_hotel_hotel_pictures POST       /admin/hotels/:hotel_id/hotel_pictures/batch_action(.:format) admin/hotel_pictures#batch_action
              admin_hotel_hotel_pictures GET        /admin/hotels/:hotel_id/hotel_pictures(.:format)              admin/hotel_pictures#index
                                         POST       /admin/hotels/:hotel_id/hotel_pictures(.:format)              admin/hotel_pictures#create
           new_admin_hotel_hotel_picture GET        /admin/hotels/:hotel_id/hotel_pictures/new(.:format)          admin/hotel_pictures#new
          edit_admin_hotel_hotel_picture GET        /admin/hotels/:hotel_id/hotel_pictures/:id/edit(.:format)     admin/hotel_pictures#edit
               admin_hotel_hotel_picture GET        /admin/hotels/:hotel_id/hotel_pictures/:id(.:format)          admin/hotel_pictures#show
                                         PATCH      /admin/hotels/:hotel_id/hotel_pictures/:id(.:format)          admin/hotel_pictures#update
                                         PUT        /admin/hotels/:hotel_id/hotel_pictures/:id(.:format)          admin/hotel_pictures#update
                                         DELETE     /admin/hotels/:hotel_id/hotel_pictures/:id(.:format)          admin/hotel_pictures#destroy

The link generated with admin_hotel_hotel_pictures_path(hotel) is corect.
But when I try to get http://0.0.0.0:3000/admin/hotels/852/hotel_pictures I get a NoMethodError : undefined method `find' for nil:NilClass
it look like the problem come from inherited_resources gem.
Admin::HotelPicturesController#evaluate_parent
line 90 of belongs_to_helpers.rb : parent = parent.send(parent_config[:finder], params[parent_config[:param]])

I'm using ruby 2.0.0-p247 & rails 4.0.0
is anybody encountered the same kind of problem?
thank you

Duplicate issue #2519: belongs_to and undefined method `find' for nil:NilClass
Created: 2013-09-30T14:32:39Z
I've a HotelPicture model belongs_to a Hotel model.

ActiveAdmin.register HotelPicture do
  config.comments = false
  menu :parent => "Hotels"

  belongs_to :hotel
end

If I check routes I've :
batch_action_admin_hotel_hotel_pictures POST       /admin/hotels/:hotel_id/hotel_pictures/batch_action(.:format) admin/hotel_pictures#batch_action
              admin_hotel_hotel_pictures GET        /admin/hotels/:hotel_id/hotel_pictures(.:format)              admin/hotel_pictures#index
                                         POST       /admin/hotels/:hotel_id/hotel_pictures(.:format)              admin/hotel_pictures#create
           new_admin_hotel_hotel_picture GET        /admin/hotels/:hotel_id/hotel_pictures/new(.:format)          admin/hotel_pictures#new
          edit_admin_hotel_hotel_picture GET        /admin/hotels/:hotel_id/hotel_pictures/:id/edit(.:format)     admin/hotel_pictures#edit
               admin_hotel_hotel_picture GET        /admin/hotels/:hotel_id/hotel_pictures/:id(.:format)          admin/hotel_pictures#show
                                         PATCH      /admin/hotels/:hotel_id/hotel_pictures/:id(.:format)          admin/hotel_pictures#update
                                         PUT        /admin/hotels/:hotel_id/hotel_pictures/:id(.:format)          admin/hotel_pictures#update
                                         DELETE     /admin/hotels/:hotel_id/hotel_pictures/:id(.:format)          admin/hotel_pictures#destroy

The link generated with admin_hotel_hotel_pictures_path(hotel) is corect.
But when I try to get http://0.0.0.0:3000/admin/hotels/852/hotel_pictures I get a NoMethodError : undefined method `find' for nil:NilClass
it look like the problem came from inherited_resources gem.
Admin::HotelPicturesController#evaluate_parent
line 90 of belongs_to_helpers.rb : parent = parent.send(parent_config[:finder], params[parent_config[:param]])

I'm using ruby 2.0.0-p247 & rails 4.0.0
is anybody encountered the same kind of problem?
thank you

Closing comment (2013-09-30T15:27:58Z): closing as a dup of #2518