Skip to content

Instantly share code, notes, and snippets.

@brookr
Created June 2, 2012 05:01
Show Gist options
  • Select an option

  • Save brookr/2856669 to your computer and use it in GitHub Desktop.

Select an option

Save brookr/2856669 to your computer and use it in GitHub Desktop.
How to link an image file to the upvote action in the q_man demo app
<h1>Listing questions</h1>
<table>
<tr>
<th>Title</th>
<th>Body</th>
<th>Votes</th>
<th>Upvote</th>
<th></th>
<th></th>
<th></th>
</tr>
<% @questions.each do |question| %>
<tr>
<td><%= question.title %></td>
<td><%= question.body %></td>
<td><%= pluralize(question.votes.length, "vote") %></td>
<td>
<%=
link_to votes_path(question_id: question.id), method: :post do
image_tag "https://encrypted-tbn1.google.com/images?q=tbn:ANd9GcTNyeijtMLI2LEU1ly0wutumFX88JMaKDhWUsn7p0pR4Vf11IB2"
end
%>
</td>
<td><%= link_to 'Show', question %></td>
<td><%= link_to 'Edit', edit_question_path(question) %></td>
<td><%= link_to 'Destroy', question, confirm: 'Are you sure?', method: :delete %></td>
</tr>
<% end %>
</table>
<br />
<%= link_to 'New Question', new_question_path %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment