Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fix for Rack apps with a Rails constant, but no Rails, and a forward-compat fix for app preload detection #2

Closed
wants to merge 2 commits into from

2 participants

@jeremy

No description provided.

@FooBarWidget
Owner

Already fixed some time ago but forgot to close the issue.

This was referenced
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 23, 2010
  1. @jeremy

    A non-Rails app may have defined a Rails constant, e.g. for compatibi…

    jeremy authored
    …lity reasons, so rails/version may be unavailable.
  2. @jeremy

    Check for Rails 3 before the Rails::Initializer constant in case that…

    jeremy authored
    …'s introduced in a later version.
This page is out of date. Refresh to see the latest.
View
6 lib/phusion_passenger/classic_rails/application_spawner.rb
@@ -257,11 +257,7 @@ def load_environment_with_passenger
end
def rails_will_preload_app_code?
- if defined?(Rails::Initializer)
- return ::Rails::Initializer.method_defined?(:load_application_classes)
- else
- return Rails::VERSION::MAJOR >= 3
- end
+ return Rails::VERSION::MAJOR >= 3 || (defined?(Rails::Initializer) && ::Rails::Initializer.method_defined?(:load_application_classes))
end
def handle_spawn_application(client, *options)
View
9 lib/phusion_passenger/utils.rb
@@ -366,8 +366,13 @@ def after_loading_app_code(options)
# Post-install framework extensions. Possibly preceded by a call to
# PhusionPassenger.install_framework_extensions!
- require 'rails/version' if defined?(::Rails) && !defined?(::Rails::VERSION)
- if defined?(::Rails) && ::Rails::VERSION::MAJOR <= 2
+ if defined?(::Rails) && !defined?(::Rails::VERSION)
+ begin
+ require 'rails/version'
+ rescue LoadError
+ end
+ end
+ if defined?(::Rails::VERSION) && ::Rails::VERSION::MAJOR <= 2
require 'phusion_passenger/classic_rails_extensions/init'
ClassicRailsExtensions.init!(options)
# Rails 3 extensions are installed by
Something went wrong with that request. Please try again.