class Member < ActiveRecord::Base belongs_to :role validates :name, :presence => {:message => "用户名不能为空"}, :uniqueness => {:message => "用户名已存在"} validates :password, :presence => {:message => "密码不能为空"} validates :role_id, :presence => {:message => "请给用户指定权限"} validates :realname, :presence => {:message => "真实姓名不能为空"} validates :tel, :presence => {:message => "电话不能为空"} # 通过缓存获取function集合 # # 作者: 汤建华 # 最后更新时间: 2013-11-23 # # ==== 返回 # 功能集合 def role_fuctions role = self.role fuctions = role.functions.all if role end def creator Member.find self.creator_id end def child_members Member.where(:creator_id => self.id) end # md5加密 # # 作者: 汤建华 # 最后更新时间: 2013-11-23 # # ==== 参数 # * 密码 # # ==== 返回 # md5码 def self.getmd5(password) Digest::MD5.hexdigest(password) end end