Skip to content

Commit b6b19f5

Browse files
committed
Use Rails eager loading for resque:preload
1 parent 7976e93 commit b6b19f5

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

lib/resque/tasks.rb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,13 @@
4242

4343
# Preload app files if this is Rails
4444
task :preload => :setup do
45-
if defined?(Rails) && Rails.env == 'production'
46-
Dir["#{Rails.root}/app/**/*.rb"].each do |file|
47-
require file
48-
end
45+
if defined?(Rails) && Rails.respond_to?(:application)
46+
# Rails 3
47+
Rails.application.eager_load!
48+
elsif defined?(Rails::Initializer)
49+
# Rails 2.3
50+
$rails_rake_task = false
51+
Rails::Initializer.run :load_application_classes
4952
end
5053
end
5154
end

0 commit comments

Comments
 (0)