In a view file of mine I have a code like this:
<td><%= link_to 'Destroy', link, method: :delete, data: { confirm: 'Are you sure ?' } %></td>
So after clicking on this it’s deleting that particular data form database. But this code is in a file named profiles/index.html.erb which is generated with the profile controller.
Now after clicking on destroy link the control is going to the links_controller.rb not profiles_controller.rb. But I want this to get redirected to profiles_controller.rb, so that I can do certain operations while deleting in my destroy action in my profiles controller and then get redirected to profiles/index.html.erb, not links/index.html.erb.
How to do this??
Thanks…
The second parameter to
link_tois the destination of the link, ie. what you’re linking to – it sounds like you’re linking to the wrong place.If you want to link to the profiles controller you need to do that (ie. change
linkto whatever your route to the correct action of the profiles controller is).