Home > Software engineering >  button_to with image Ruby on Rails
button_to with image Ruby on Rails

Time:05-05

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".

CodePudding user response:

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>
  • Related