Using Rails link_to for links that post

后端 未结 5 1037

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

5条回答
  •  抹茶落季
    2020-12-02 14:46

    The parameters and the http method should be together {param1: 'value1', param2: 'value2', :method: :post}

    <%= link_to "Profile", profile_path(@profile), {param1: 'value1', param2: 'value2', method: :post} %>
    

提交回复
热议问题