views:

30

answers:

2

I have the following code:

<% @recipe.instructions.each do |instruction| %>
  <li><%= instruction %></li>
<% end %>

I get the following error: undefined method 'each' for #<String:0xa354eb8>

@recipe.instructions is defined as text

Please help!

Reese

+3  A: 

Use each_line instead of each. String#each has been removed in ruby 1.9, each_line works with all ruby versions.

sepp2k
Thanks that did the trick!
Reese
+1  A: 

What about String#each_line? It should work with both Ruby 1.8 and 1.9.

klickverbot