我有一个模型screenshot.rb。
定义为rake任务
namespace :clean_up_temp do
desc "clean up unsaved screenshots 1 hours ago"
task :screenshots => :environment do
Screenshot.destroy_all([ 'created_at<? AND title IS NULL', 1.hours.ago ])
end
end
它在当地运作良好。
Heroku失败
Running `rake clean_up_temp:screenshots` attached to terminal... up, run.2861
rake aborted!
uninitialized constant Screenshot
/app/lib/tasks/clean_up_temp_screenshots.rake:3:in `block in <top (required)>'
/app/lib/tasks/clean_up_temp_screenshots.rake:1:in `<top (required)>'
/app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/engine.rb:641:in `block in run_tasks_blocks'
/app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/engine.rb:641:in `each'
/app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/engine.rb:641:in `run_tasks_blocks'
/app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/application.rb:244:in `run_tasks_blocks'
/app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/engine.rb:446:in `load_tasks'
/app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/railtie/configurable.rb:30:in `method_missing'
/app/Rakefile:6:in `<top (required)>'
(See full trace by running task with --trace)
我也试过添加
config.dependency_loading = true if $rails_rake_task
in production.rb
我该如何解决这个问题