This project is archived and is in readonly mode.

#3994 ✓invalid
Marc Love

ActiveSupport 3 doesn't autoload core extensions

Reported by Marc Love | February 18th, 2010 @ 09:24 PM

Update: In fact it seems none of ActiveSupport's core extensions are autoloaded anymore. Is that intentional?

If so, it would seem unwise. There's a plethora of libraries out there which depend on those core extensions. I just ran into another related issue where requiring ActiveMerchant fails because it depends on the existence of HashWithIndifferentAccess.

require 'rubygems'
require 'active_support'
class Person
  cattr_accessor :type

results in:

NoMethodError: undefined method 'cattr_accessor' for Person:Class from (irb):4

The old (and deprecated) loading method of "require 'activesupport'" works just fine though:

require 'rubygems'
require 'activesupport'
class Person
  cattr_accessor :type

This raises no error and works as expected.

Comments and changes to this ticket

  • Marc Love

    Marc Love February 18th, 2010 @ 10:49 PM

    • Tag changed from activesupport, cattr_accessor to active_support core_ext, activesupport, core_ext
    • Title changed from “require "active_support" doesn't provide cattr_accessor method” to “ActiveSupport 3 doesn't autoload core extensions”
  • Jacques Crocker

    Jacques Crocker February 19th, 2010 @ 08:29 AM

    Pretty sure this is intentional. If you want everything in active_support you need to use require 'active_support/all'

    That's generally a terrible idea though. The best approach for ActiveSupport 3.0 is to pick out the exact require that you need for the feature you are using. That way you avoid the overhead of loading the entire library.

  • Marc Love

    Marc Love February 19th, 2010 @ 10:39 PM

    Good to know Jacques. Thanks for the info.

    It would be nice if the core team would mention this on the Rails blog. I'm sure there's going to be plenty of gem/plugin repositories out there that are going to need updating.

  • José Valim

    José Valim February 23rd, 2010 @ 09:31 PM

    • State changed from “new” to “invalid”

    Yup, this is intentional as discussed in the mailing list.

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>

People watching this ticket