'button_to with image Ruby on Rails

I want to put an image that works as a button. For the moment I have this:

<td><%= button_to '+1', upvote_submission_path(submission), method: :post %></td>

This works, however, I don't know how to put an image called grayarrow.gif instead of the "+1".



Solution 1:[1]

You should be able to simply replace the text with a image_tag like this:

<td>
  <%= button_to(image_tag('grayarrow.gif').html_safe, 
                upvote_submission_path(submission), 
                method: :post) %>
</td>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1