Get DOM-friendly IDs from your Rails objects

Post by Peter Cooper

Permanent Link  |   book mark Get DOM-friendly IDs from your Rails objects in del.icio.usClick here to add on del.icio.us

Another new article in Bruce's series shows you how to get DOM-friendly IDs from ActiveRecord. This is a solution nearly all Rails developers have implemented at some time or another:

<ul>
<% @entries.each do |entry| %>
  <li id='journal-entry-<%= entry.id %>'>
    <%= entry.body %>
  </li>
<% end %>
</ul>

But Bruce demonstrates a cleaner way..

Comments are closed.