我想在@post 视图中触发邮件“操作”。
class UserMailer < ActionMailer::Base
default from: "example@gmail.com"
def newsletter(post)
@greeting = ""
@users = User.all
@users.each do |user|
mail to: user.email, subject: post.title
end
end
end
= button_to 'Deliver' do
UserMailer.newsletter(@post).deliver
end
如果我按下此按钮,它会在明显存在时弹出错误“No route matches posts/6”。