Search code examples
ruby-on-railscssrubyruby-on-rails-3positioning

How do you get this div to wrap around an image link?


I have this image link:

<%= link_to image_tag(comment.user.profile.photo.url(:tiny)), profile_path(comment.user.profile), :class => "comment_image" %>

and I want to wrap a div containing 1. text and 2. a list with a link and text around that image link. I want the image to be on the left, and the div to be on the right wrapping around the image.

enter image description here


Solution

  • Assuming you don't need any of the fancier features offered by the link_to helper, the easy answer is to just use an anchor tag directly.

    <a href="<%= profile_path(comment.user.profile) %> class="comment_image">
      <div>
        Some stuff -- whatever
        <%= image_tag(comment.user.profile.photo.url(:tiny)) %>
        Some more stuff -- ya know...
      </div>
    </a>