This works:
>> class Foo
>> def xyz()
>> Foo.subclasses
>> end
>> end
=> nil
>> class Bar < Foo
>> end
=> nil
>> class Quux < Bar
>> end
=> nil
>> Foo.new.xyz()
=> ["Quux", "Bar"]
But this doesn't. User
is a class in my application.
>> User.subclasses
NoMethodError: protected method `subclasses' called for #<Class:0x20b5188>
from [...]/vendor/rails/activerecord/lib/active_record/base.rb:1546:in `method_missing'
from (irb):13
But this does!
>> Foo.subclasses
=> ["Quux", "Bar"]
What's going on here? How would I list the subclasses of User
?