Я использую этот учебник, чтобы получить внутренние сообщения работают на моем сайте: http://www.novawave.net/public/rails_messaging_tutorial.htmlВнутренний обмен сообщениями в Rails
Но, начиная с моего последнего обновления до Rails 3, я получаю эту ошибку:
NoMethodError in MsgController#sendmsg
undefined method `each' for #<String:0xcc8acc0>
след
Применение:
app/models/message.rb:16:in `prepare_copies'
app/controllers/msg_controller.rb:140:in `sendmsg'
модель Сообщение:
class Message < ActiveRecord::Base
belongs_to :author, :class_name => "User"
has_many :message_copies
has_many :recipients, :through => :message_copies
before_create :prepare_copies
attr_accessor :to # array of people to send to
attr_accessible :subject, :body, :to
def prepare_copies
return if to.blank?
to.each do |recipient|
recipient = User.find(recipient)
message_copies.build(:recipient_id => recipient.id, :folder_id => recipient.inbox.id)
end
end
end
Нам нужен ваш контроллер msg_controller, потому что он находится в их ошибке. – shingara