Sachin Prasad
Sachin Prasad

Reputation: 5411

link on image and text in ruby on rails

I want to convert this into ruby on rails code :

<a href="#"><span>Log out</span><%= image_tag("images/log-out.png") %></a>

When trying this one:

<%= link_to image_tag("images/log-out.png", :border => 0 ), destroy_user_session_path, :method => :delete %>

I'm getting a link on the image. But i also need to add span with text.I tried this but its not working:-

 <%= link_to "<span>Log out</span>"+image_tag("images/log-out.png", :border => 0 ), destroy_user_session_path, :method => :delete %>

Upvotes: 0

Views: 529

Answers (1)

jaco
jaco

Reputation: 3506

Try with:

 <%= link_to raw("<span>Log out</span>") + image_tag("images/log-out.png", :border => 0 ), destroy_user_session_path, :method => :delete %>

Upvotes: 1

Related Questions