添加此代码
def send_messages
return if recipient_list.blank?
recipient_list.each do |recipient|
recipient = User.find(recipient)
messages.build(user_id: recipient.id, conversation_id: self.id)
end
到我的模特
class Conversation < ActiveRecord::Base
attr_accessible :recipient_list
after_create :send_messages
has_many :messages
end
导致对我的模型的任何引用抛出
syntax error, unexpected $end, expecting keyword_end
从模型中......没有它,我的模型完美无缺。这段代码有问题吗?
答案 0 :(得分:4)
你错过了关闭do块的结束:
def send_messages
return if recipient_list.blank?
recipient_list.each do |recipient|
recipient = User.find(recipient)
messages.build(user_id: recipient.id, conversation_id: self.id)
end
end