abiao лет назад: 4
Родитель
Сommit
08320232ac

+ 5 - 2
app/models/product.rb

@@ -7,7 +7,7 @@ class Product < ActiveRecord::Base
     scope :inactive, -> { where(ptype: "direct_sale") }
     belongs_to :product_cat, :foreign_key => :category_id
     belongs_to :merchant, :foreign_key => :merchant_id
-    validates :name,:buy_price,:price,:category_id,:count,:robo_balance_price,:relate_product_id, presence: true
+    validates  :product_no,:name,:buy_price,:price,:category_id,:count,:robo_balance_price,:relate_product_id, presence: true
     validate :product_validation
 
     def product_validation
@@ -171,7 +171,8 @@ class Product < ActiveRecord::Base
               enum do 
                 TYPE_ENUM
               end
-            end 
+            end
+            field :product_no
             #field :category_id
             field :product_cat
             field :detail
@@ -230,6 +231,7 @@ class Product < ActiveRecord::Base
                 TYPE_ENUM
               end
             end
+            field :product_no
             #field :category_id
             field :product_cat
             field :detail
@@ -292,6 +294,7 @@ class Product < ActiveRecord::Base
                 TYPE_ENUM
               end
             end
+            field :product_no
             #field :category_id
             field :merchant_id
             field :product_cat

+ 2 - 1
config/locales/models/product.yml

@@ -57,4 +57,5 @@ zh-CN:
         package: 是否套装
         product_cycle: 生产周期
         stock_cycle: 备货周期
-        min_purchase: 最低进货量
+        min_purchase: 最低进货量
+        product_no: 商品编号

+ 11 - 0
db/migrate/20210726032357_add_product_no_column_to_products.rb

@@ -0,0 +1,11 @@
+# This migration and CreateVersionAssociations provide the necessary
+# schema for tracking associations.
+class AddProductNoColumnToProducts < ActiveRecord::Migration
+  def self.up
+    add_column :products, :product_no, :string,:limit => 128,:null => false, :default => ""
+  end
+
+  def self.down
+    remove_column :products, :product_no
+  end
+end