This project is archived and is in readonly mode.

#2638 ✓stale
Graeme Mathieson

rails/info causes frameworks that are not already loaded to be (partially?) loaded

Reported by Graeme Mathieson | May 12th, 2009 @ 05:15 PM | in 3.x

For one particular project, running on Rails 2.3, we do not need ActiveRecord. In config/environment.rb, I have removed the ActiveRecord framework: do |config|
  # [ ... ]
  # Skip frameworks you're not going to use. To use Rails without a database,
  # you must remove the Active Record framework.
  config.frameworks -= [ :active_record, :action_mailer ]

Unfortunately, a call to Rails::Info causes ActiveRecord to be defined, as you can see from this console session:

mathie@Tullibardine booger (master) $ script/console
Loading development environment (Rails 2.3.2)
Object.con>> Object.const_defined?("ActiveRecord")
=> false
>> Rails::Info
=> About your application's environment
Ruby version              1.8.6 (universal-darwin9.0)
RubyGems version          1.3.3
Rack version              1.0
Rails version             2.3.2
Active Record version     2.3.2
Action Pack version       2.3.2
Active Resource version   2.3.2
Action Mailer version     2.3.2
Active Support version    2.3.2
Application root          /Users/mathie/booger
Environment               development
>> Object.const_defined?("ActiveRecord")
=> true

This causes a problem because some parts of Rails, the generated skeleton application and several plugins check to see if ActiveRecord is defined to test for database support.

The plugin in particular, which both calls Rails::Info and checks for the existence of ActiveRecord in order to enable portions of itself, is New Relic's RPM Agent (which is why I'm about to point those guys at this report too!).

Attached is a patch without tests -- I'll attempt to work on tests just now, but I could always use the help. :-)

Comments and changes to this ticket

  • Graeme Mathieson

    Graeme Mathieson May 12th, 2009 @ 05:39 PM

    Got the tests sussed, I think. Attached is a new patch, with tests this time.

  • Frederick Cheung

    Frederick Cheung May 12th, 2009 @ 08:00 PM

    Cool, I've been bitten by this one (also with new relic and a databaseless app). Not someone with a checkout of rails handy, but isn't removing the ActiveRecord constant going to mess up other tests. Perhaps you could put it back afterwards (in an ensure) or mock out the call to const_defined ?

    Also you should rebase down to a single patch.

  • Bill

    Bill May 12th, 2009 @ 11:15 PM

    +1 We also had this problem in NewRelic. As a side effect of collecting Rails information we broke apps that did not include the AR framework.

    The patch looks good to me. I thought maybe you could get the frameworks list from the configuration object and use that as a test instead, but there are probably tradeoffs between both approaches I'm not aware of. Just a thought.

  • Graeme Mathieson

    Graeme Mathieson May 20th, 2009 @ 06:54 AM

    @Frederick: Removing ActiveRecord doesn't seem to be messing up other tests -- I've run the full Rails test suite without issue. Thanks for the squashing tip -- I've attached a new version of the patch which is flattened.

    @Bill Unfortunately, you can't get the frameworks list from the configuration object because it splits out action controller into action view & action pack, which is not what Rails::Info wants to see.

  • Jeremy Kemper

    Jeremy Kemper May 4th, 2010 @ 06:48 PM

    • Milestone changed from 2.x to 3.x
  • Rohit Arondekar

    Rohit Arondekar October 9th, 2010 @ 04:14 AM

    • State changed from “new” to “stale”
    • Importance changed from “” to “”

    Marking ticket as stale. If this is still an issue please leave a comment with suggested changes, creating a patch with tests, rebasing an existing patch or just confirming the issue on a latest release or master/branches.

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>