2010-08-30 71 views
0

這是我沒有表的常用模型。如何在rails中獲取我的模型的層次結構

class CommonActiveRecord < ActiveRecord::Base 

    self.abstract_class = true 

    def before_validation 
    set_blank_attributes_to_nil(@attributes) 
    end 

end 

我的其他車型看起來像這樣..

class BalanceName < CommonActiveRecord 

    def before_validation 
    super 
    end 

end 

我想獲取BalanceName的所有超..

此命令返回超只有一個級別

>> BalanceName.superclass 
=> CommonActiveRecord(abstract) 

我怎麼可能得到超類的層次?

回答

2
BalanceName.ancestors will give you an array of all superclasses