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
:
- https://coderedirect.com/questions/280885/rails-button-to-applying-css-class-to-button
- adding {} did not change anything
- Rails 'button_to' is not working with 'send_file' method
- using it with
method: 'get'
had no effect.
- using it with
- Nested icons and Rails' link_to or button_to are not working with SLIM
- putting icon before path gives error and indenting the second block gives strange output
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?