ruby on rails - Method for finding the days when you need to send mail -


i can not write method send letters days used create company.

the user created company created_at: "2014-04-24 11:39:35" , indicated how company ended ends_at: 4, 4 days after creation of company end.

also specify days in notify first_reminder_day: 3, second_reminder_day: 1.

i write method send notification users regarding completion of company.

class campaign < activerecord::base   def dispatch_emails     @campaigns = campaign.where("ends_at < ?",  time.now + first_reminder_day.day )     @campaigns.each |campaign|       campaignends.notify(campaign, first_reminder_day).deliver     end   end end  class campaignends < basemailer   def notify(campaign, day)     @title = campaign.title     @day = day     mail(to: 'to@example.com', subject: "the company #{@title} ends in #{@day} days")   end end 

how use 2 values search first_reminder_day , second_reminder_day in search?


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -