瀏覽代碼

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"