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 by Bill on February 6, 2008 - 5:50 pm
It’s a good thing. To do this in Java it seems you need JSP or some kind of additional templating engine. No need with Ruby.