我正在尝试运行后台邮件程序,并根据文章的参数,将不同的用户转储到邮件列表中。应要求撰写新文章,我收到此错误:
Actor crashed!
NoMethodError: undefined method `email' for #<User::ActiveRecord_Relation:0x007fca99f657c8>
这是逻辑:
def create
@article = Article.new(article_params)
@all_users = []
if @article.football == true
@all_users << User.where( :sport => "Football").all
elsif @article.basketball == true
@all_users << User.where("users.sport LIKE ?", "%Basketball%").all
elsif @article.volleyball == true
@all_users << User.where( :sport => "Volleyball").all
elsif @article.lacrosse == true
@all_users << User.where( :sport => "Lacrosse").all
else
@all_users = User.all
end
if @article.save
@all_users.each do |user|
ArticleMailer.new.async.article_confirmation(user,@article)
end
redirect_to @article
else
render 'new'
end
end