I have been going over rails scheduling tasks options and stumbled upon this piece of code from whenever.
case @environment
when 'production'
every 1.day, :at => "#{Time.parse('12:00 A').getlocal.strftime("%H:%M")}" do
runner "Company.send_later(:create_daily_stories!)"
end
when 'staging'
every 15.minutes do
command "thinking_sphinx_searchd reindex"
end
end
I am fairly new to ruby and I dont quite understand what “Company” here stands for. In other words say i want to send an email out to people and i have a controller class called email_controller in which I have a method called sendEmail and I want to send emails using this how would i do it? Should i say runner”email_controller.sendEmail” or something like that? I dont quite get it. Note – Do i use the model or controller in place of company?
In this case,
Companyis an example model that has a class/singleton method calledcreate_daily_stories!. In theory, it would probably look like this:Ideally, generating emails resides in the business logic and should thusly be contained within a model (assuming you’re using an MVC framework like rails).