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.

NoMethodError when using 'class_attribute'

#4812

require "active_support/all" # or /core_ext

Class Foo; class_attribute :bar; end # raises NoMethodError

Reported by Chris Sepic · June 9th, 2010 @ 06:04 PM

State: resolved
Milestone: none
Assigned to: Yehuda Katz (wycats) Yehuda Katz (wycats)
Importance: Low

Activity

  1. Neeraj Singh
    Neeraj Singh

    How is your project setup? Can you elaborate on that. Thanks.

    June 9th, 2010 @ 07:41 PM

  2. Chris Sepic
    Chris Sepic

    Neeraj - I'm just requiring the latest activesupport (activesupport-3.0.0.beta4) in irb:

    irb(main):001:0> gem "activesupport", "3.0.0.beta4"
    => true
    irb(main):002:0> require "active_support/core_ext"
    => true
    irb(main):003:0> class Foo; class_attribute :bar; end
    NoMethodError: undefined method `class_attribute' for Foo:Class
    from (irb):3:in `<class:Foo>'
    from (irb):3
    from /Users/csepic/.rvm/rubies/ruby-1.9.1-p378/bin/irb:15:in `<main>'
    irb(main):004:0>
    

    June 9th, 2010 @ 08:54 PM

  3. Chris Sepic
    Chris Sepic

    Looking in class.rb, there is simply no "require" for attribute.rb. I don't know if there is a reason for this.

    June 9th, 2010 @ 08:56 PM

  4. Prem Sichanugrist (sikachu)
    Prem Sichanugrist (sikachu)
    • State changed from new to verified
    • Assigned user set to Yehuda Katz (wycats)

    You're definitely right, here is the patch for it.

    June 11th, 2010 @ 12:48 AM

  5. Prem Sichanugrist (sikachu)
    Prem Sichanugrist (sikachu)
    • State changed from verified to resolved
    • Importance changed from to Low

    This ticket was resolved a while ago, but seems like José forgot to add # in commit message!

    http://github.com/rails/rails/commit/6c4bab306ae1ee47b7fe5933867d32...

    September 10th, 2010 @ 01:44 PM

  6. alasiri