I have a page model and a pages_controller within an admin namespace. My routes file looks like this:
map.resources :pages, :only => [:index,:show]
map.resources :admin, :only => [:index]
map.namespace :admin do |admin|
admin.resources :pages
end
I am not able to figure out the correct method to create a link for deleting a page (In the same way the scaffold generator generates a delete link on the index page).
Any ideas on the correct parameters for the link_to function?
TIA,
Adam
rake routesis your friend here. It’ll spit out the list of your generated routes – particularly useful if you have a bunch of nested or custom routes.the paths will be
Your link_to for delete should therefore be:
Note that Rails will work its magic calling
to_paramon @page, so that you don’t have to specify @page.id – useful for an example like this as you often want to use permalinks for ‘pages’.