member for THU

This commit is contained in:
Matthew K. Fu JuYuan authored and chris committed 2012-10-26 11:19:56 +08:00
1 parent 579c7b5e81
commit 0a1a9d2c2e
14 files changed
+162 -123

No files matched your search

+15
View File
@@ -35,10 +35,22 @@ class User
before_create :initialize_desktop
before_save :check_status_record
before_save :save_roles
scope :remote_account, where(:nccu_id.ne => nil)
validates_uniqueness_of :email,:message=> I18n.t("devise.registrations.email_not_unique")
# def new_attribute_values=(vars)
# binding.pry
# end
# def new_attribute_values(vars)
# binding.pry
# end
def rebuild_sub_roles_from_attribute_values!(attribute_values)
# attribute_fields = AttributeField.find attribute_values.collect{|t| t[1][:attribute_field_id]}
# self.sub_roles = attribute_fields.collect{|t| t.attribute if t.attribute.is_a? SubRole}.compact.uniq
end
def set_sub_role(sub_role_id,status_id)
self.sub_roles << SubRole.find(sub_role_id)
@@ -131,6 +143,9 @@ class User
end
protected
def save_roles
self.roles = self.sub_roles.collect{|t| t.role}.uniq
end
def check_status_record
roles = sub_roles.collect{|t| t.role}.uniq #get all role from sub_roles