employ.rb 886 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. end
  13. end
  14. end
  15. rails_admin do
  16. navigation_label '食堂管理'
  17. weight -500
  18. list do
  19. filters [:mobile,:wx_user_id,:user_name]
  20. field :id
  21. field :user_name
  22. field :mobile
  23. field :wx_user_id
  24. field :created_at
  25. # field :updated_at
  26. end
  27. show do
  28. field :id
  29. field :user_name
  30. field :mobile
  31. field :wx_user_id
  32. field :created_at
  33. field :updated_at
  34. end
  35. edit do
  36. field :user_name
  37. field :mobile
  38. end
  39. end
  40. end