簡體   English   中英

帶有圖像 Ruby on Rails 的 button_to

[英]button_to with image Ruby on Rails

我想放置一個用作按鈕的圖像。 目前我有這個:

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

這有效,但是,我不知道如何放置一個名為 grayarrow.gif 的圖像而不是“+1”。

您應該能夠像這樣簡單地用image_tag替換文本:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM