ソースを参照

wx user depart => shop applyction depart

abiao 5 年 前
コミット
52e617549a
共有1 個のファイルを変更した7 個の追加0 個の削除を含む
  1. 7 0
      app/models/shop_application.rb

+ 7 - 0
app/models/shop_application.rb

@@ -4,7 +4,14 @@ class ShopApplication < ActiveRecord::Base
   self.table_name = "shop_applications"
   DEPART_ENUM= [["部门1",1], ["部门2",2], ["部门3", 3], ["部门4", 4], ["部门5", 5]]
   belongs_to :depart_record, :foreign_key => :depart
+  before_save :before_save
 
+  def before_save
+    wxUser = WxUser.where("id = ?", self.wx_user_id).first
+    if !wxUser.blank?
+      self.depart=wxUser.depart
+    end
+  end
   IMG_STORE_PATH = "shop"