Reputation:
If I have a block of the following format:
<% @model.each do |f| %>
<%= f.name %>
<%= image_tag("some_picture.jpg") %>
<br>
<% end %>
How do I get it to repeat itself horizontally, instead of vertically? If the list is long enough to reach the end of its containing div, I would like for it to continue a line down, like normal html text.
Upvotes: 1
Views: 267
Reputation: 38645
This concatenates the names array using Array#join with a single space between them:
<%= @model.map(&:name).join(' ') %>
Wrapping this within a paragraph element would give you what you are looking for:
<%= content_tag(:p, @model.map(&:name).join(' ')) %>
Upvotes: 2