Rails image_tag pointer (Chrome-specific feature?)
Link to my rendered view in Chrome
In my Rails application (companies view), I wanted each 'company' to be displayed with its logo having a height of 125px. I figured I'd leave the width undefined so that the browser would render it according to each image's aspect ratio. Interestingly, Rails (or Chrome?) doesn't seem to recognize 'height' alone within the image_tag, but 'size' works exactly as I was hoping.
Here's my code:
<body>
<div class="row-fluid">
<div class="span9 list-group">
<% @companies.each do |company| %>
<ul class="well nav nav-pills">
<li><%= link_to company.name, company_path(company) %></li>
<li><%= link_to(image_tag(company.logo, size: "125", class: "media"), company_path(company)) %></li>
</ul>
<% end %>
</div>
</div>
</body>
Written by Matt Campbell
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Chrome
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#