I' m building a rails application where I use action mailer. I wanna be able to send email per say 2 hours before a certain event.
def notification(user, event)
@user = user
@event = event
@delivery_time = @event.start_at - INTERVAL '2 hour'
mail( to: @user.email,
subject: "Upcoming event")
end
event.start_at is timestamp format.
would it be possible to do
event.start_at - INTERVAL - '2 hours'
I know you can do something like that into postgresql
timestamp '2001-09-28 23:00' - interval '23 hours'
according to Postgresql .