class ProductAttrConfig < ActiveRecord::Base has_paper_trail self.table_name = 'product_attr_configs' belongs_to :product_attr_key, :foreign_key => :attr_key_id validates :size_type,presence:true def show_products showProducts=[[]] @products = Product.where("show_flag=1").order("created_at desc") @products.each do |pd| a=[pd.id,pd.name] showProducts.push(a) end showProducts.each {|v| puts v} return showProducts end rails_admin do navigation_label '商品管理' weight -250 parent ProductAttrKey nestable_tree({ position_field: :position, max_depth: 2 }) list do filters [:product_id,:product_attr_key] field :id field :product_id field :show_products field :product_attr_key field :size_type end show do field :id field :product_id field :product_attr_key field :size_type end edit do field :product_id field :product_attr_key field :size_type end end end