Sha256: 1a6c540dcc32058a754e4f7ce2f16e9138ca140b1a9eb8dff8e504738a92591e
Contents?: true
Size: 1.32 KB
Versions: 3
Compression:
Stored size: 1.32 KB
Contents
module Saucy module Account extend ActiveSupport::Concern included do has_many :account_memberships, :dependent => :destroy has_many :users, :through => :account_memberships has_many :projects, :dependent => :destroy has_many :admins, :through => :account_memberships, :source => :user, :conditions => { 'account_memberships.admin' => true } belongs_to :plan validates_uniqueness_of :name, :url validates_presence_of :name, :url attr_accessible :name, :url validates_format_of :url, :with => %r{^[a-z0-9]+$}, :message => "must be only lower case letters." validates_exclusion_of :url, :in => %w[app admin blog dev ftp mail pop pop3 imap smtp staging stats status www], :message => 'is reserved.' end module InstanceMethods def to_param url end def has_member?(user) account_memberships.exists?(:user_id => user.id) end def users_by_name users.by_name end def projects_by_name projects.by_name end def projects_visible_to(user) projects.visible_to(user) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
saucy-0.1.3 | lib/saucy/account.rb |
saucy-0.1.2 | lib/saucy/account.rb |
saucy-0.1.1 | lib/saucy/account.rb |