# Noob - nested resource and destroy

**URL:** <https://www.ruby-forum.com/t/noob-nested-resource-and-destroy/148520>\
**Category:** Rails\
**Created:** [September 14, 2008, 6:48am UTC](https://www.ruby-forum.com/t/noob-nested-resource-and-destroy/148520 "2008-09-14T06:48:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![richardchaven](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e480ec/32.png) [@richardchaven](https://www.ruby-forum.com/u/richardchaven)\
**Post date:** [September 14, 2008, 6:48am UTC](https://www.ruby-forum.com/t/noob-nested-resource-and-destroy/148520/1 "2008-09-14T06:48:11Z")

</div>

Hello

I have an articles controller and an admin/articles…routes.rb:

map.resource :articles

map.namespace :admin do |admin|  
admin.resources :articles  
end

Normally I could refer to the admin\_article\_path series of  
routes…edit\_admin\_article\_path(asdf) for example - but a link\_to for  
destroy isn’t working out. It’s looking in the Articles controller  
rather than the Admin::Articles controller.

I’ve tried:

\<%= link\_to ‘Destroy’, admin\_article  
article  
admin\_article\_path

etc etc - always get an undefined local variable or method.

I did just notice in my controllers/admin/articles\_controller.rb that  
I’m doing things like:

@articles = Article.find,etc rather than Admin::Article find - maybe  
this could be it…im crossing controllers up?

Any help would be greatly appreciated

---

<div class="post-metadata">

**Author:** ![richardchaven](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e480ec/32.png) [@richardchaven](https://www.ruby-forum.com/u/richardchaven)\
**Post date:** [September 14, 2008, 7:23am UTC](https://www.ruby-forum.com/t/noob-nested-resource-and-destroy/148520/2 "2008-09-14T07:23:02Z")

</div>

On Sep 14, 12:48 pm, Richard Mr [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Normally I could refer to the admin\_article\_path series of  
> etc etc - always get an undefined local variable or method.
> 
> I did just notice in my controllers/admin/articles\_controller.rb that  
> I’m doing things like:
> 
> @articles = Article.find,etc rather than Admin::Article find - maybe  
> this could be it…im crossing controllers up?
> 
> ## Any help would be greatly appreciated
> 
> Posted viahttp://www.ruby-forum.com/.

Try this:

link\_to “Destroy”, admin\_article\_url(@article), :confirm =\> “Are you  
sure you want to delete this article?”, :method =\> :delete

You can omit the confirm parameter if you wish.

BTW, the above uses javascript, so it won’t work if your user has  
javascript disabled. The reason being for it is that the destroy call  
has to be wrapped in a POST method.
