0
2週間後にメールを送信する方法をメーラーに設定しようとしています。作成された電子メールをデータベースから取り出して「メール(to:...)」に入れても問題ありません...コンソールからリクエストするとメールを送信できます。Ruby ActionMailer。新しいメールに送信
目標は、新しい場所が追加されるたびに、14日後に指定のメールアドレスにメールが送信されるようにすることです。 ここに私のapp/mailerがあります。
class Place < ApplicationRecord
belongs_to :user
after_create :send_alert_email
geocoded_by :address
after_validation :geocode
validates :name, presence: true
validates :name, length: {minimum: 3,
too_short: " %{count} or more characters are required."}
validates :address, presence: true
validates :phone, length: { is: 10}
def send_alert_email
NotificationMailer.reminder(self).deliver(wait: 1.hour)
end
end
class NotificationMailer < ApplicationMailer
default from: "[email protected]"
def reminder(email)
@email = email
mail(to: @place.email,
subject: "Reminder: your box is going to be picked up in fourteen days")
end
end
MY MODELはあなたのすべての助けのためのみんなに感謝します。
を使用することができますが、14日に、あなたの 'NotificationMailer'に待ち時間を設定しようとしたことがありますか? –
ねえ!私は数時間だけ数学をやろうとしていました。私は、新しい場所が提出されたときにデータベースからメールを引き出して問題を見つけたと思う。 –