我需要這個圖像鏈接到profile_path(thing.user)使用的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)使用的link_to使圖像的鏈接
<%= image_tag thing.user.photo.url(:small), { :class=>"rounded_square" ,
style: "margin-left:8px; text-align:center; vertical-align:middle;" } %>
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 %>
= link_to somewhere_path(some_object) do
= image_tag some_object.url, class: 'rounded_square'
end
塊的返回值將成爲a
標籤的內容。
你可以使用嵌套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-04 18:49:07