|
|
@@ -1,10 +1,21 @@
|
|
|
class ProductAttrConfig < ActiveRecord::Base
|
|
|
has_paper_trail
|
|
|
self.table_name = 'product_attr_configs'
|
|
|
- has_ancestry
|
|
|
- has_many :products, :foreign_key => :category_id
|
|
|
+ belongs_to :product_attr_key, :foreign_key => :attr_key_id
|
|
|
validates :name,presence:true
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+ def show_products
|
|
|
+ showProducts=[[]]
|
|
|
+ @products = Product.where("show_flag=1").order("created_at desc")
|
|
|
+ @products.each do |pd|
|
|
|
+ a=[pd.id,pd.title]
|
|
|
+ showProducts.push(a)
|
|
|
+ end
|
|
|
+ showProducts.each {|v| puts v}
|
|
|
+ return showProducts
|
|
|
+ end
|
|
|
+
|
|
|
rails_admin do
|
|
|
navigation_label '商品管理'
|
|
|
weight -250
|
|
|
@@ -18,20 +29,21 @@ class ProductAttrConfig < ActiveRecord::Base
|
|
|
filters [:product_id,:attr_key_id]
|
|
|
field :id
|
|
|
field :product_id
|
|
|
- field :attr_key_id
|
|
|
+ field :showProducts
|
|
|
+ field :product_attr_key
|
|
|
field :type
|
|
|
end
|
|
|
|
|
|
show do
|
|
|
field :id
|
|
|
field :product_id
|
|
|
- field :attr_key_id
|
|
|
+ field :product_attr_key
|
|
|
field :type
|
|
|
end
|
|
|
|
|
|
edit do
|
|
|
field :product_id
|
|
|
- field :attr_key_id
|
|
|
+ field :product_attr_key
|
|
|
field :type
|
|
|
end
|
|
|
end
|