Skip to content

Commit

Permalink
Use Rails eager loading for resque:preload
Browse files Browse the repository at this point in the history
  • Loading branch information
defunkt committed Aug 30, 2011
1 parent 7976e93 commit b6b19f5
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/resque/tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,13 @@

# Preload app files if this is Rails
task :preload => :setup do
if defined?(Rails) && Rails.env == 'production'
Dir["#{Rails.root}/app/**/*.rb"].each do |file|
require file
end
if defined?(Rails) && Rails.respond_to?(:application)
# Rails 3
Rails.application.eager_load!
elsif defined?(Rails::Initializer)
# Rails 2.3
$rails_rake_task = false
Rails::Initializer.run :load_application_classes
end
end
end

0 comments on commit b6b19f5

Please sign in to comment.