employ.rb 886 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. # encoding: utf-8
  2. class Employ < ActiveRecord::Base
  3. self.table_name = "employs"
  4. validates :mobile,:user_name,presence: true
  5. validate :employ_validation
  6. def employ_validation
  7. usr = User.where("tel = ?", self.mobile).first
  8. if usr.blank?
  9. wu = WxUser.where("user_id = ?", usr.id).first
  10. if !wu.blank?
  11. self.wx_user_id = wu.id
  12. self.save
  13. end
  14. end
  15. end
  16. rails_admin do
  17. navigation_label '食堂管理'
  18. weight -500
  19. list do
  20. filters [:mobile]
  21. field :id
  22. field :user_name
  23. field :mobile
  24. field :wx_user_id
  25. field :created_at
  26. # field :updated_at
  27. end
  28. show do
  29. field :id
  30. field :user_name
  31. field :mobile
  32. field :wx_user_id
  33. field :created_at
  34. field :updated_at
  35. end
  36. edit do
  37. field :user_name
  38. field :mobile
  39. end
  40. end
  41. end