new on rails and using windows for now,,
i have web page that user insert name, date and email. depending on his date input i want to send him email(if @dop.date=date.now-7.days then send email
). how could i implement it?? i want the system get user dates and check it if user insert date, and the date has been for 7 days then send him email...
class UserMailer < ActionMailer::Base
default from: "from@example.com"
def welcome_email(dop)
@dop = dop
@url = "http://example.com/login"
mail(:to => dop.mail, :subject => "Welcome to My Awesome Site")
end
end
def create
@dop = Dop.new(params[:dop])
respond_to do |format|
if @dop.save
UserMailer.welcome_email(@dop).deliver
format.html { redirect_to @dop, notice: 'Dop was successfully created.' }
format.json { render json: @dop, status: :created, location: @dop }
else
format.html { render action: "new" }
format.json { render json: @dop.errors, status: :unprocessable_entity }
end
end
end
here is my model: class Dop < ActiveRecord::Base attr_accessible :date,:mail,:name validates_presence_of:name validates_presence_of:mail validates_uniqueness_of:mail
end