Posts Tagged love

Happiness is Ruby on Rails

Ruby on Rails is such a beautiful thing… Here’s some view (presentation) code that I slapped together in about 2 minutes:

  <% Category.find(:all).each { |category| %>
    <div id=<%= category.cssid %>>
      <h2><%= category.Name %></h2>
      <ul>
        <% category.items.find(:all).each { |item| %>
        <li><%= item.ShortDescription %></li>
      <% } %>
      </ul>
    </div>
  <% } %>

Basically, it let’s me easily list out categories and then items within those categories on a webpage (with per-category styling supported). It’s interleaved with HTML and produces very slick output. It just feel so natural and that’s what I love about it.

, ,

1 Comment