我需要将此图片链接到 profile_path(thing.user)
<%= image_tag thing.user.photo.url(:small), { :class=>"rounded_square" ,
style: "margin-left:8px; text-align:center; vertical-align:middle;" } %>
答案 0 :(得分: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 %>
答案 1 :(得分:1)
= link_to somewhere_path(some_object) do
= image_tag some_object.url, class: 'rounded_square'
end
块的返回值将成为a
标记的内容。
答案 2 :(得分: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)" %>