Rake Task in Rails 3 on Production ENV
Cannot execute Rake Task in production environment? Does it throws errors of uninitialized objects or refuses to load Model classes?
To execute a rake task for eager loading we require,
config.threadsafe! to be disabled in production which is enabled by default.
But our requirement is to get it disabled only on running a rake task.
Rake already sets a Ruby global: $rails_rake_task
So, in config/environments/production.rb, just say:
config.threadsafe! unless $rails_rake_task