Nested resources and collection

Hello guys!

I have smth like this in my routes.rb

map.resource :admin do |admin|

admin.resources   :galleries,
                  :name_prefix  => :admin_,
                  :controller   => 'admin/galleries' do |gallery|

  gallery.resources :images, :collection => { :checked => :delete},
                    :name_prefix  => :admin_,
                    :controller => 'admin/images'

end
end

This worked fine until i needed to add extra method to REST crud (to
perform action on checked items through form and checkboxes). I added a
method called checked in my images controller.

But when i try to use: form_tag checked_images_path, :method => :delete
in my view
i get undefined local variable or method `checked_images_path’.

Its probably something simple but i can’t see it.

thx

Hey,

I’m not 100% sure but I think it’s because you have name_prefix set to
“admin_”, so the it would be “admin_checked_images_path”. Give that a
try and let us know if that works.

AryaAsemanfar wrote:

Hey,

I’m not 100% sure but I think it’s because you have name_prefix set to
“admin_”, so the it would be “admin_checked_images_path”. Give that a
try and let us know if that works.

Thanks for reply.

I tried that, but still i get
undefined local variable or method `admin_checked_images_path’
This is strange.

Pawel Jur wrote:

AryaAsemanfar wrote:

Hey,

I’m not 100% sure but I think it’s because you have name_prefix set to
“admin_”, so the it would be “admin_checked_images_path”. Give that a
try and let us know if that works.

Thanks for reply.

I tried that, but still i get
undefined local variable or method `admin_checked_images_path’
This is strange.

Ok, I think i solved it. Since its nested it needs another parameter.

<% form_tag admin_checked_images_path(@gallery), :method => :delete do
%>

that did the trick. Now i can finally make checkboxes.

Yes that’s it! I just got the same problem yesterday!

So, with that parameter, your are only able to administer checked
images related to a gallery at a time, isn’t it?
Have you found a cool way to administer all of them at a time, keeping
a pretty RESTful design?

Thanks.