Kaynağa Gözat

增加商品属性定义

abiao 5 yıl önce
ebeveyn
işleme
fb9bebd790
1 değiştirilmiş dosya ile 7 ekleme ve 6 silme
  1. 7 6
      app/models/product_attr.rb

+ 7 - 6
app/models/product_attr.rb

@@ -1,8 +1,9 @@
 class ProductAttr < ActiveRecord::Base
     has_paper_trail
     self.table_name = 'product_attrs'
-    has_ancestry
-    validates :name,presence:true
+
+    belongs_to :product_attr_key, :foreign_key => :attr_key_id
+    validates :name,:product_attr_key,presence:true
     
     rails_admin do
         navigation_label '商品管理'
@@ -14,22 +15,22 @@ class ProductAttr < ActiveRecord::Base
         })
 
         list do 
-            filters [:name,:attr_key_id]
+            filters [:name,:product_attr_key]
             field :id
-            field :attr_key_id
+            field :product_attr_key
             field :name 
             field :recommend
         end
 
         show do
             field :id
-            field :attr_key_id
+            field :product_attr_key
             field :name
             field :recommend
         end
 
         edit do 
-            field :attr_key_id
+            field :product_attr_key
             field :name
             field :recommend
         end