Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Rails::Info requires version for unwanted frameworks

#3124

Currently, Rails::Info will attempt to load framework/version for all frameworks, even ones that have been opted out of via config.frameworks -=.

Problems arise because the top level framework constant, e.g. ActiveRecord, is defined when active_record/version is required, and this messes with detection of the framework's existence via:

defined?(ActiveRecord)

...which is done in ActionController::Dispatcher.define_dispatcher_callbacks, rake db:test:prepare, and in many external libraries. Things break, because these libraries aren't actually loaded, just the bare module with the VERSION module included.

The problem only happens when Rails::Info is called, either via the default rails info page, or when required by a library. One particularly popular external library that requires Rails::Info: the New Relic RPM plugin.

To fix this, I'm just checking to see if the constant is defined before requiring 'framework_name/version'. Another way to fix this would be, to use Rails.configuration.frameworks.

I couldn't figure out a way to write a proper test for this.

Reported by Geoff Buesing · September 1st, 2009 @ 01:05 AM

State: committed
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. Geoff Buesing
    Geoff Buesing

    I'm having a problem uploading my patchfile to Lighthouse -- but this is what the change looks like:

          def framework_version(framework)
            if Object.const_defined?(framework.classify)
              require "#{framework}/version"
              "#{framework.classify}::VERSION::STRING".constantize
            end
          end
    

    September 1st, 2009 @ 01:07 AM

  2. Geoff Buesing
  3. Repository
    Repository
    • State changed from new to committed

    September 1st, 2009 @ 10:30 AM

  4. Repository