Sign up ×
Code Review Stack Exchange is a question and answer site for peer programmer code reviews. It's 100% free, no registration required.

What is the most elegant and readable way to in include (potentially long) image_tag calls inside of link_to?


<%= link_to image_tag('buckminsterfullerene.png', width: '210', height: '60', alt: 'Molecular structure of Buckminsterfullerene'), 'some_long_path.html', title: 'Buckminsterfullerene', rel: 'tooltip', relative: true %>
share|improve this question

1 Answer 1

You could create a helper to keep your views less bloated. For example:


def image_link_to(image_path, url, image_tag_options = { }, link_to_options = { })
  link_to url, link_to_options do
    image_tag image_path, image_tag_options


= image_link_to "buckminsterfullerene.png", my_url_helper, { size: '210x60', alt: 'Molecular structure of Buckminsterfullerene' }, { title: 'Buckminsterfullerene', rel: 'tooltip', relative: true }
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.