Rails link_to or button_to post request with parameters

前端 未结 4 511
悲哀的现实
悲哀的现实 2020-12-24 06:52

I have a restful (scaffold generated) controller and model for Votes, I am simply trying to add a field into the view that when clicked, will create a new vote for a given c

4条回答
  •  暖寄归人
    2020-12-24 07:39

    You can also pass your parameters as an argument to your path helper like so

    <%= button_to '+', votes_path(car_id: card.id), method: 'post'  %>
    

    You can fetch your session id from your controller or still pass it to the paths helper if you want.

提交回复
热议问题