Ruby, Rails, and brute force

I’ve started teaching myself to work with Ruby on Rails. And since I’m a hands on guy I tend to get myself into odd situations and have to brute force myself out. For example last night I was dealing with trying to display a number of records from a database (there were only 3 records) and all I could get it to display was

###

Well it turns out that when using embedded ruby (eRuby) these two blocks of code are VERY different.

## This works
<% for i in Network.find(:all) %>
  <%= h i.name %>
<% end %>

and

## This doesnt
<%=
  for i in Network.find(:all)
    h i.name
  end
%>

Ahh, it’s always the little things in life which give you the greatest joy and the greatest frustration!

Leave a Reply