Sha256: 27a95e356fea5fbf40e87c042f9d2d8e2b37c9b191ad57eb1b51ea70d4b9dc36
Contents?: true
Size: 796 Bytes
Versions: 2
Compression:
Stored size: 796 Bytes
Contents
module Saucy module User extend ActiveSupport::Concern included do attr_accessible :name, :project_ids, :email, :password has_many :memberships has_many :accounts, :through => :memberships has_many :permissions has_many :projects, :through => :permissions validates_presence_of :name end def admin_of?(account) memberships.exists?(:account_id => account.id, :admin => true) end def member_of?(account_or_project) account_or_project.has_member?(self) end module ClassMethods def search(query) return [] if query.nil? where ['users.email like :query or users.name like :query', { :query => "%#{query}%" }] end def by_name order('users.name') end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
saucy-0.16.1 | lib/saucy/user.rb |
saucy-0.16.0 | lib/saucy/user.rb |