I have a link with which I need to send a sending request. I usually use jQuery and prevent the default link behavior, and then submit the form to the recipient. It seems like Rails should help me. Of course, the link_to method has the ability to specify the POST http method:
link_to "Profile", 'http://example.com/profile', method: :post
This works, but I need to add 2 parameters as well. I tried:
link_to "Profile", 'http://example.com/profile', method: post, param1: 'value1', param2: 'value2'
It simply added these parameters to the <a> HTML element, but did not send them when the link was clicked:
<a rel="nofollow" param1="value1" param2="value2" data-method="post" href="http://example.com/profile">Profile</a>
Is there a way to make a POST request with parameters using link_to or any other Rails method? I am using Rails 3.2.9.
at. Nov 16 '12 at 10:24 2012-11-16 10:24
source share