I have a link that I need to submit a post request with. Normally, I\'d use jQuery and prevent the link\'s default behavior and then submit a form to the destination. This s
Note that if the user has JS disabled or you have removed the unobtrusive JS libraries that come by default, link_to
will be silently submitted via a GET
request.
In general, I am not very fond of having links that perform POST
requests. I think that's the role of a form and a button.
Thus, an easy (and safer) alternative is to use the Rails button_to helper:
button_to 'Profile', profile_path(@profile, param1: 'value1', param2: 'value2')
button_to
also supports the method
option but as it defaults to post
so I've just omitted it.