开发者

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

开发者 https://www.devze.com 2023-01-10 20:17 出处:网络
I hav开发者_开发知识库e the following code: <% @recipe.instructions.each do |instruction| %>

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

精彩评论

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