开发者

how to fetch hierarchy of my model in rails

开发者 https://www.devze.com 2023-01-13 22:25 出处:网络
This is my common model which has no table. class CommonActiveRecord < 开发者_如何学运维ActiveRecord::Base

This is my common model which has no table.

class CommonActiveRecord < 开发者_如何学运维ActiveRecord::Base

  self.abstract_class = true

  def before_validation
    set_blank_attributes_to_nil(@attributes)
  end

end

My other models look like this ..

class BalanceName < CommonActiveRecord

  def before_validation
    super
  end

end

I want to fetch all superclasses of BalanceName..

This command is returning only one level superclass

>> BalanceName.superclass
=> CommonActiveRecord(abstract)

how may i get hierarchy of superclasses ??


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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号