Model commit

This commit is contained in:
Harry Bomrah committed 2012-04-03 18:25:41 +08:00
1 parent bbd2c23b3d
commit 4250c26c88
7 files changed
+71 -3

No files matched your search

+7 -1
View File
@@ -16,11 +16,13 @@ class User
has_many :privilege_apps, :inverse_of => :privilege_users, :class_name => "AppAuth"
has_many :managing_apps,:class_name => "AppManager"
has_one :desktop, :autosave => true, :dependent => :destroy
belongs_to :role
has_and_belongs_to_many :sub_roles
accepts_nested_attributes_for :attribute_values, :allow_destroy => true
before_create :initialize_desktop
def avb_apps
sub_role_ids_ary=self.sub_roles.collect{|t| t.id}
query1 = AppAuth.any_in({sub_role_ids: sub_role_ids_ary}).excludes(blocked_user_ids: self.id)
@@ -53,4 +55,8 @@ class User
User.find(id) rescue nil
end
def initialize_desktop
self.build_desktop
end
end