rails 3 model associations model with rails_admin -


could 1 me please associations in rails app. models:

class catalog < activerecord::base     attr_accessible :name     has_many :parent_catalogs end   class parentcatalog < activerecord::base     attr_accessible :catalog_id, :name     has_many :child_catalogs     belongs_to :catalog end   class childcatalog < activerecord::base     attr_accessible :name, :parent_catalog_id     has_many :products     belongs_to :parent_catalog end   class product < activerecord::base   attr_accessible :child_catalog_id, :name   belongs_to :child_catalog       # ex       rails_admin         field :name         field :child_catalog           # how ((         end       end end 

question is: how can make child_catalog field like: catalog.name + parentcatalog.name + childcatalog.name in product edit menu...

put code in childcatalog model

def self.fullname  self.parent_catelog.catelog.name + self.parent_catelog.name + self.name  end 

Comments