I hav开发者_开发知识库e 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
Use each_line
instead of each
. String#each
has been removed in ruby 1.9, each_line
works with all ruby versions.
What about String#each_line
? It should work with both Ruby 1.8 and 1.9.
精彩评论