- "div_for", content_tag. , HTML- , , "div_for" .
, , , , , JS. HTML :
<% @people.each do |p| %>
<div id="person_<%= p.id %>"><%= p.name %></div>
<% end %>
It would be annoying if you would do LOTS of this with multiple attributes (I usually use custom identifiers, classes, and some data attributes). But using div_for, you can write above:
<% @people.each do |p| %>
<%= div_for(p) do %><%= @person.name %><% end %>
<% end %>
Makes HTML a little easier to read when things get long and complicated. I found that when working with javascript it is much cleaner.
http://apidock.com/rails/ActionView/Helpers/RecordTagHelper/div_for
Dan l source
share