I want to output the following with Ruby on Rails link_to and image_tag methods:
<a href="#">Lorem Ipsum <img src="/images/menu-arrow-down.gif"></a>
What would be a good way in Rails?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Why not just use a link to and image tag?
You could also try the appending done above (
string + image_tag), but it will throw an error if one of those things becomesnil. Using interpolation, it will just show a blank image(or string) if it isnil.For Rails 3, you will need to use
html_safe: