My rake looks like this:
task :cron => :environment do
Email.signup_email_reminder
end
And my Email.signup_email_reminder methods looks like this:
class Email
include ActiveModel::Validations
include ActiveModel::Conversion
extend ActiveModel::Naming
.
.
.
def self.signup_email_reminder
User.any_in(:status => [:status1, :status2]).each do |user|
puts Data.get_country_code(user.locale).upcase
end
end
.
.
.
end
the method get_country_code is a static class in the model Data:
class Data
def self.get_country_code(locale)
.
.
end
.
.
.
end
But every 开发者_高级运维time I run the rake I get an error saying that the get_country_code method does not exist :(
$ rake cron --trace
(in /Volumes/alexandre.ponsin/Documents/Project/TextMaster.com)
** Invoke cron (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute cron
rake aborted!
undefined method `get_country_code' for Data:Class
I don't know what to do here :(
Alex
My guess is namespace collision. There's already a class called Data, so you may want to think about renaming your model.
$: rails console
Loading development environment (Rails 3.0.3)
ruby-1.8.7-p330 :001 > Data
=> Data
精彩评论