Reputation: 99
I need to link this image to profile_path(thing.user)
<%= image_tag thing.user.photo.url(:small), { :class=>"rounded_square" ,
style: "margin-left:8px; text-align:center; vertical-align:middle;" } %>
Upvotes: 1
Views: 1836
Reputation: 3615
You could try it with nested erb.
<%= link_to "#{image_tag(yourimagepath)}", "link_path" %>
Should look something like this.
<%= 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)" %>
Upvotes: 0
Reputation: 3366
link_to
should take a block if nothing helps:
<%= 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 %>
Upvotes: 4
Reputation: 6310
= link_to somewhere_path(some_object) do
= image_tag some_object.url, class: 'rounded_square'
end
The return value of the block becomes the content for the a
tag.
Upvotes: 1