开发者

Getting error trying to display string split on new lines - Ruby on Rails

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜