0

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 %>
2
  • Please refer this same question stackoverflow.com/questions/5387122/… Commented Nov 12, 2012 at 14:45
  • Saw but it didn't work. It was simply printing out the HTML code. Commented Nov 12, 2012 at 14:58

1 Answer 1

1

Try with:

 <%= link_to raw("<span>Log out</span>") + image_tag("images/log-out.png", :border => 0 ), destroy_user_session_path, :method => :delete %>
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks buddy this one worked for me. I will accept this as an answer after some time as stack won't allow me to do it now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.