class ProductAttr < ActiveRecord::Base
    has_paper_trail
    self.table_name = 'product_attrs'

    belongs_to :product_attr_key, :foreign_key => :attr_key_id
    validates :name,:product_attr_key,presence:true
    
    rails_admin do
        navigation_label '商品管理'
        weight -250
        parent ProductAttrKey
        nestable_tree({
            position_field: :position,
            max_depth: 2
        })

        list do 
            filters [:name,:product_attr_key]
            field :id
            field :product_attr_key
            field :name 
            field :recommend
            field :status
        end

        show do
            field :id
            field :product_attr_key
            field :name
            field :recommend
            field :status
        end

        edit do 
            field :product_attr_key
            field :name
            field :recommend
            field :status
        end 

    end

end