我希望用户每天能够发送不超过5封电子邮件。有没有可能验证?Actionmailer验证发送的最大电子邮件
user_mailer.rb
class UserMailer < ActionMailer::Base
def contact_email(from_email, body, to_email)
@body = body
@user = User.find_by(email: to_email)
mail(from: from_email, to: to_email, subject: '', cc: from_email)
end
end
users_controller.rb
def send_mail
@user = User.find(params[:id])
@body = params[:message]
UserMailer.contact_email(current_user.email, @body, @user.email).deliver_now
end
试试这个=> UserMailer.contact_email(current_user.email,@body,@ user.email).deliver_now如果 –
@mokariya任何一世dea逻辑可能是什么样子? – Ray