Internal messaging in Rails

眉间皱痕 提交于 2019-12-04 20:45:43

That tutorial seems a bit dated. It uses Rails 2.0 (and probably some equally old Ruby version).

Are you sure that to holds an Array (as indicated in your attr_accessor comment)? The error message seems to indicate that it is a String.

Did you previously have this code running under Ruby 1.8 (and, presumably, a version of Rails 2.3)?

In Ruby 1.8 you could send each to String instances and it would (by default) iterate on the lines of the string (actually it would split on $/ and iterate on the result).

In Ruby 1.9 you need to use each_line to iterate over the lines of a string.

to.each_line do |recipient|
  …
end

Seems you to is no anymore an Array but a String now. You problem semmes becomes from your controller and how you define your to accessor inside it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!