I am trying to use the Whenever plugin for rails to perform a model process at certain times. My schedule.rb is as follows:
every 1.day, :at => '5:30 am' do
runner "User.mail_out"
end
My model is as follows:
class User < ActiveRecord::Base
acts_as_authentic
def mail_out
weekday = Date.today.strftime('%A').downcase
@users = find(:conditions => "#{weekday}sub = t")
@users.each { |u| UserMailer.deliver_mail_out(u)}
end
end
When I try to run the script/runner -e development "User.mail_out" command, I get the following error:
/var/lib/gems/1.8/gems/rails-2.3.5/lib/commands/runner.rb:48: undefined method `mail_out' for #<Class:0xb708bd50> (NoMethodError)
from (eval):1
from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `eval'
from /var/lib/gems/1.8/gems/rails-2.3.5/lib/commands/runner.rb:48
from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
from script/runner:3
Can anyone point out what is going wrong? Also how can I manually invoke the mail_out process (from command line) to test the functionality of my mailing system.
Thank you!