Hi, In my project, all delete links aren''t working. They keep acting as "show" action. Here is an example for the announcements controller. In routes.rb : map.resources :announcements In my index view, I have the standard <%= link_to ''Destroy'', announcement, :confirm => ''Are you sure?'', :method => :delete %> But when ever I click on the link, controller gets a "get" message, not a "delete". Processing AnnouncementsController#show (for 127.0.0.1 at 2009-03-02 14:01:23) [GET] Session ID: 95ccbfa93eef0bf8408147c7b6b9a287 Parameters: {"action"=>"show", "id"=>"2", "controller"=>"announcements", "locale"=>"en"} In order to get the delete working I had to create a new named route. map.annoucements_delete "announcements/:id/ delete", :controller=>"announcements", :action => "destroy" <%= link_to ''delete'', annoucements_delete_path(announcement), :confirm => ''Are you sure?'', :method => :delete %> It works, but it is ugly. What did I do wrong ? Thanks Jean-Loup --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Mon, Mar 2, 2009 at 5:20 AM, jlf <jlfenaux-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hi, > > In my project, all delete links aren''t working. They keep acting as > "show" action. > > Here is an example for the announcements controller. > > In routes.rb : > > map.resources :announcements > > In my index view, I have the standard > <%= link_to ''Destroy'', announcement, :confirm => ''Are you > sure?'', :method => :delete %> > > But when ever I click on the link, controller gets a "get" message, > not a "delete". > > Processing AnnouncementsController#show (for 127.0.0.1 at 2009-03-02 > 14:01:23) [GET] > Session ID: 95ccbfa93eef0bf8408147c7b6b9a287 > Parameters: {"action"=>"show", "id"=>"2", > "controller"=>"announcements", "locale"=>"en"} > > In order to get the delete working I had to create a new named route. > > map.annoucements_delete "announcements/:id/ > delete", :controller=>"announcements", :action => "destroy" > > <%= link_to ''delete'', annoucements_delete_path(announcement), :confirm > => ''Are you sure?'', :method => :delete %> > > It works, but it is ugly. > > What did I do wrong ? > Thanks > Jean-LoupIn my very very small example, the following works for me: *<%= link_to "delete", announcement**_path(**announcement**), **:confirm => "Are you sure?", :method => :delete** %>* Good luck, -Conrad --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Do you have javascript enabled in the browser you''re testing the delete action with? <%= link_to ''Destroy'', announcement, :method => :delete %> produces an anchor tag to the show action but with a bunch of javascript code to emulate the DELETE http method. On Mon, Mar 2, 2009 at 12:35 PM, Conrad Taylor <conradwt-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Mon, Mar 2, 2009 at 5:20 AM, jlf <jlfenaux-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >> Hi, >> >> In my project, all delete links aren''t working. They keep acting as >> "show" action. >> >> Here is an example for the announcements controller. >> >> In routes.rb : >> >> map.resources :announcements >> >> In my index view, I have the standard >> <%= link_to ''Destroy'', announcement, :confirm => ''Are you >> sure?'', :method => :delete %> >> >> But when ever I click on the link, controller gets a "get" message, >> not a "delete". >> >> Processing AnnouncementsController#show (for 127.0.0.1 at 2009-03-02 >> 14:01:23) [GET] >> Session ID: 95ccbfa93eef0bf8408147c7b6b9a287 >> Parameters: {"action"=>"show", "id"=>"2", >> "controller"=>"announcements", "locale"=>"en"} >> >> In order to get the delete working I had to create a new named route. >> >> map.annoucements_delete "announcements/:id/ >> delete", :controller=>"announcements", :action => "destroy" >> >> <%= link_to ''delete'', annoucements_delete_path(announcement), :confirm >> => ''Are you sure?'', :method => :delete %> >> >> It works, but it is ugly. >> >> What did I do wrong ? >> Thanks >> Jean-Loup > > In my very very small example, the following works for me: > > <%= link_to "delete", announcement_path(announcement), :confirm => "Are you > sure?", :method => :delete %> > > Good luck, > -Conrad > > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---