Sha256: 48d985b644e7f4bcb1b43f4d70b99181f27696b407372424d87fda309b518b21
Contents?: true
Size: 1.01 KB
Versions: 3
Compression:
Stored size: 1.01 KB
Contents
module Saucy module User extend ActiveSupport::Concern included do attr_accessible :name, :project_ids, :email, :password_confirmation, :password has_many :project_memberships has_many :projects, :through => :project_memberships has_many :account_memberships has_many :accounts, :through => :account_memberships validates_presence_of :name end module InstanceMethods def admin_of?(account) account_memberships.exists?(:account_id => account.id, :admin => true) end def member_of?(account_or_project) account_or_project.has_member?(self) end def update_permissions_for(account, project_ids) project_ids_for_other_accounts = projects. reject { |project| project.account_id == account.id }. map { |project| project.id } self.project_ids = project_ids + project_ids_for_other_accounts end end module ClassMethods def by_name order('users.name') end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
saucy-0.1.3 | lib/saucy/user.rb |
saucy-0.1.2 | lib/saucy/user.rb |
saucy-0.1.1 | lib/saucy/user.rb |