# Nested resources and collection

**URL:** <https://www.ruby-forum.com/t/nested-resources-and-collection/108743>\
**Category:** Rails\
**Created:** [July 6, 2007, 3:31pm UTC](https://www.ruby-forum.com/t/nested-resources-and-collection/108743 "2007-07-06T15:31:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![pabloz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c37758/32.png) [@pabloz](https://www.ruby-forum.com/u/pabloz)\
**Post date:** [July 6, 2007, 3:31pm UTC](https://www.ruby-forum.com/t/nested-resources-and-collection/108743/1 "2007-07-06T15:31:24Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![pabloz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c37758/32.png) [@pabloz](https://www.ruby-forum.com/u/pabloz)\
**Post date:** [July 6, 2007, 6:15pm UTC](https://www.ruby-forum.com/t/nested-resources-and-collection/108743/2 "2007-07-06T18:15:10Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![pabloz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c37758/32.png) [@pabloz](https://www.ruby-forum.com/u/pabloz)\
**Post date:** [July 6, 2007, 8:42pm UTC](https://www.ruby-forum.com/t/nested-resources-and-collection/108743/3 "2007-07-06T20:42:58Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![pabloz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c37758/32.png) [@pabloz](https://www.ruby-forum.com/u/pabloz)\
**Post date:** [July 7, 2007, 1:03am UTC](https://www.ruby-forum.com/t/nested-resources-and-collection/108743/4 "2007-07-07T01:03:43Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![pabloz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c37758/32.png) [@pabloz](https://www.ruby-forum.com/u/pabloz)\
**Post date:** [July 9, 2007, 11:53am UTC](https://www.ruby-forum.com/t/nested-resources-and-collection/108743/5 "2007-07-09T11:53:43Z")

</div>

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.
