Possible Duplicate:
how to keep sending emails to users every week depending on user date input in rails
I am building a system that allows a user to insert info name, date, and email. I want the system to automatically send emails to its users every 7 days from which they inserted.
here`s my mailer
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
and this is controller:
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