Paul wrote:
> I am looking on how I could do something like the following,
>
>Foo < AR::Base
>Bar < Foo.
>
>I would like to list all Foo''s, but because Bar.is_a? Foo == true I
>would like Bars to list as well.
>
>Any ideas? Or pointers in the right direction? I know there is a ruby
>command to list subclasses, or ancestors (don''t have my pickaxe
handy)
>but seem to remember it listing only models that are also have been
>used in a method.
>
>
Not precisely sure what you want to do, but ancestors lists all
classes the receiver inherit from:
irb(main):001:0> require ''active_record''
=> true
irb(main):002:0> class Table < ActiveRecord::Base
irb(main):003:1> end
=> nil
irb(main):004:0> class Table2 < Table
irb(main):005:1> end
=> nil
irb(main):007:0> Table2.ancestors
=> [Table2, Table, ActiveRecord::Base, ActiveRecord::Acts::NestedSet,
ActiveRecord::Acts::List, ActiveRecord::Acts::Tree,
ActiveRecord::Reflection, ActiveRecord::Transactions,
ActiveRecord::Aggregations, ActiveRecord::Associations,
ActiveRecord::Timestamp, ActiveRecord::Callbacks, ActiveRecord::Locking,
ActiveRecord::Validations, ClassInheritableAttributes, Object, Kernel]