How can i make conditions on sending emails to users based on date which they insert??
using if statement, without using gems.
users insert name,email and date. then based on date they inserts, system checks the date if today = date they insert + 7days then send email?? where should i type this?? is it in usermailer, or “Dop” controller???
user mailer:
class UserMailer < ActionMailer::Base
default from: "bla bla bla"
def welcome_email(dop)
@dop = dop
@url = "blah blah"
mail(:to => dop.mail, :subject => "Welcome to My Awesome Site")
end
end
“Dop” refers to date of pregnancy
In my view, the UserMailer should only be concerned with the actual creating and shipping of the e-mail. If UserMailer is called, you should already have decided that you want the e-mail to ship.
So in your case, I assume you have a create action in a controller, which instructs the Mailer to send the e-mail. Here you simply encapsulate this action in an if statement.
this asumes you use something like this in your form: