I have a piece of code that works fine in the console, but in a cron-driven rake task, it errors out every time, saying that the accessor function for one of the has_many relationships is not a valid method. Example:
provider has_many instances, so I'm calling provider.instances, and the rake task will throw back an error:
"undefined method `instances' for "#<Provider:0x7fff1c18a5d8>":Provider"
In the console, the same function pasted in works fine.
The rake call:
rake RAILS_ENV=production scheduled:update_recurring --trace
The console initialization:
script/console production
Rails version 2.3.2
See anything obvious?
UPDATE: The rake file is setup as so:
namespace :scheduled do
task :update_recurring => :environment do
Stuff that worked in console but not rake here
end
end