class ProductCat < ActiveRecord::Base
    has_paper_trail
    self.table_name = 'product_cats'
    has_ancestry
    has_many :products, :foreign_key => :category_id
    validates :name,presence:true
    
    rails_admin do
        navigation_label '商品管理'
        weight -240
        nestable_tree({
            position_field: :position,
            max_depth: 2
        })

        list do 
            filters [:name,:ancestry,:position]
            field :id
            field :name 
            field :position 
            field :ancestry
            field :status
            field :products
        end

        show do
            field :id
            field :name 
            field :position 
            field :ancestry
            field :status
            field :products
        end

        edit do 
            field :name 
            field :status
            field :products
        end 

    end

end