urlhelper - what is the right 'rails' way to add a link_to a new custom method -
we're adding new method 'delete_stuff' widgetscontroller of scaffolded app.
in routes added match 'widget/delete_stuff/:id' => 'widgets#delete_stuff'
i can manually create html (get) links
<a href="/widget/delete_stuff/<% widget.id %>">my custom delete stuff</a> but that's bad on many levels (uses instead of delete, doesn't permit confirm dialog, isnt dry, etc)
problem can't figure out how use url helpers custom method... trying this:
<% link_to 'deletestuff', @widget, :confirm => 'are sure?', :method => :delete %> but gets ignored when html rendered.
i'm missing fundamental on how use link_to, appreciated!
cheers, jp
first run rake routes know url helpers available you. may see line beginning with:
delete_stuff_widget you can append path or url name should use in views , controllers. suspect new link_to like:
link_to "deletestuff", delete_stuff_widget_path(@widget), :confirm => "sure?", :method => :delete
Comments
Post a Comment