【发布时间】:2015-03-17 06:46:58
【问题描述】:
每次发布博客文章时,我都会尝试向所有用户发送电子邮件。 Mailgun 似乎会发送电子邮件,但总是只发送给一个用户。我正在生产中运行它。
我在邮件中的代码是这样的
def new_record_notification(users)
@users = User.all
@users.each do |user|
mail to: user.email, subject: "Success! You did it."
end
end
end
pins_controller.rb
# POST /pins
# POST /pins.json
def create
@pin = current_admin.pins.new(pin_params)
respond_to do |format|
if @pin.save
ModelMailer.new_record_notification(@record).deliver
format.html { redirect_to @pin, notice: 'Pin was successfully created.' }
format.json { render action: 'show', status: :created, location: @pin }
else
format.html { render action: 'new' }
format.json { render json: @pin.errors, status: :unprocessable_entity }
end
end
end
【问题讨论】:
-
能否请您发布调用此邮件方法的代码
-
当然,我编辑了问题
标签: ruby-on-rails email devise mailgun