Ah sorry. Very late in the day. Thanks heaps. On Fri, Jul 30, 2010 at 4:41 PM, Keith Pitt <[email protected]> wrote:
> Hi Sven, > > Try: > > Notifier.deliver_hour_record_expiry_notification(a,b) > > Cheers, > > Keith > > On Fri, Jul 30, 2010 at 4:06 PM, Sven Schott <[email protected]>wrote: > >> Hi guys >> >> I'm trying to use ActionMailer to send notifications outside of my >> controllers from a rake task but I'm getting an error saying the method is >> undefined. >> >> NoMethodError: undefined method `hour_record_expiry_notification' for >> Notifier:Class >> >> The ActionMailer class looks like this: >> >> class Notifier < ActionMailer::Base >> ADMIN_ADDRESS = "xx...@xxxxx" >> def hour_record_expiry_notification(recipient,hour_record) >> recipients recipient.email_address_with_name >> from ADMIN_ADDRESS >> subject "Freetime: WARNING - Hours expire in 10 days or less" >> body :user => recipient, :hour_record => hour_record >> content_type "text/html" >> end >> end >> >> and the rake task looks like this: >> >> namespace :freetime do >> desc "Find hours that will expire soon and notify the owners" >> task :notify_expiry => :environment do >> a = User.find(5);b = HourRecord.find(129) >> Notifier.hour_record_expiry_notification(a,b) >> Rails.logger.info "Sent users expiry notifications." >> end >> end >> >> Notifier.instance_methods shows the method but I'm thinking there's some >> tricker involved since it isn't an instance. :) >> >> I've googled around but I can't find anyone having the same problem which >> leads me to believe I'm doing something stupid or nobody does mail >> notifications with rake (This is a one off that runs from a cron job). Any >> ideas? I normally would crack my head a bit more but it's 4:30 and if I go >> home without solving it, I'll have to use the old shotgun. >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ruby or Rails Oceania" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]<rails-oceania%[email protected]> >> . >> For more options, visit this group at >> http://groups.google.com/group/rails-oceania?hl=en. >> > > > > -- > *Keith Pitt* > Web: http://www.keithpitt.com > Twitter: @keithpitt > Skype: keithpitt > Phone: +61 432 713 987 > > -- > You received this message because you are subscribed to the Google Groups > "Ruby or Rails Oceania" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<rails-oceania%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/rails-oceania?hl=en. > -- You received this message because you are subscribed to the Google Groups "Ruby or Rails Oceania" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rails-oceania?hl=en.
