Sha256: fa442f651b5a3c4a11a6517e9794bc82dd40ff4c0037890cff4429206e6514fe
Contents?: true
Size: 1.35 KB
Versions: 7
Compression:
Stored size: 1.35 KB
Contents
module Saucy module Account extend ActiveSupport::Concern included do has_many :memberships, :dependent => :destroy has_many :users, :through => :memberships has_many :projects, :dependent => :destroy has_many :admins, :through => :memberships, :source => :user, :conditions => { '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) 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 def memberships_by_name memberships.by_name end end end end
Version data entries
7 entries across 7 versions & 1 rubygems