1

我需要将此图像链接到profile_path(thing.user)

<%= image_tag thing.user.photo.url(:small), { :class=>"rounded_square" ,
    style: "margin-left:8px; text-align:center; vertical-align:middle;" } %>
4

3 回答 3

4

link_to如果没有任何帮助,应该阻止:

<%= link_to profile_path(thing.user) do %>
    <%= image_tag thing.user.photo.url(:small), { :class=>"rounded_square" ,
style: "margin-left:8px; text-align:center; vertical-align:middle;" } %>
<% end %>
于 2013-05-04T18:45:22.500 回答
1
= link_to somewhere_path(some_object) do
  = image_tag some_object.url, class: 'rounded_square'
end

块的返回值成为a标签的内容。

于 2013-05-04T18:44:05.093 回答
0

您可以尝试使用嵌套 erb。

<%= link_to "#{image_tag(yourimagepath)}", "link_path" %>

应该看起来像这样。

     <%= link_to "#{image_tag thing.user.photo.url(:small), 
        { :class=>'rounded_square' , style: "margin-left:8px; text-align:center; vertical-align:middle;" }}", 
       "profile_path(thing.user)" %>
于 2013-05-04T18:54:53.463 回答