Reputation: 986
I want to trigger a put method for voting with emojis but button_to is not working with slim in rails
I have the following:
= button_to vote_backend_session_path(@session.id, emoji: emoji), method: :put, remote: true, class: "btn btn-vote btn-xs bg-dark border-white hover-primary" do
i.material-icons.align-middle. #{emoji.to_s}
span.align-middle.text-white.ms-2 = @session.total(emoji)
it output the following in developer console:
So everytime a post action is triggered and my controller says it can't find the specified route.
I tried to change only in developer console to put, but then it triggers an GET
instead of PUT
I looked at several questions regarding button_to
:
method: 'get'
had no effect.I looked at the API doc as well here and was not able to find a solution.
So how to fix this and use button_to with rails in my case?
Upvotes: 0
Views: 375
Reputation: 2397
your button type is submit
, which will trigger the form to submit its fields
it shouldn't be inside a form tag you can use the CSS technique to make it look like inside the form
Upvotes: 1