On Sep 14, 12:48 pm, Richard Mr
<rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:> 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
> --
> 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.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---