Explorar o código

admin details multple

abiao %!s(int64=4) %!d(string=hai) anos
pai
achega
ffd07e9771
Modificáronse 1 ficheiros con 5 adicións e 2 borrados
  1. 5 2
      app/models/order.rb

+ 5 - 2
app/models/order.rb

@@ -11,6 +11,7 @@ class Order < ActiveRecord::Base
 
     has_many :order_details
     has_many :base_details
+    has_and_belongs_to_many :products, join_table: :order_details
 
     before_save :before_save
     #after_update :after_update
@@ -128,7 +129,9 @@ class Order < ActiveRecord::Base
     rails_admin do 
         navigation_label '商品管理'
         weight -240
-
+        configure :products do
+            inverse_of :order_details
+        end
         list do
             scopes [nil,:未支付,:已关闭,:处理中,:待收货,:已完成]
             filters [:order_id,:status,:pay_way,:receive_time,:wx_user_id,:paied_time,:depart]
@@ -326,7 +329,7 @@ class Order < ActiveRecord::Base
             field :order_remark
             field :dispatch_time
             field :depart
-            field :order_details
+            field :products
 
          end