Sha256: ff25ab1737b327c6d50944ef36b121a50ca0817598f4dfde847e9a9325901f86
Contents?: true
Size: 1.75 KB
Versions: 3
Compression:
Stored size: 1.75 KB
Contents
module Saucy module Account extend ActiveSupport::Concern included do include Saucy::Subscription 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 delegate :free?, :billed?, :trial?, :to => :plan validates_uniqueness_of :name, :keyword validates_presence_of :name, :keyword, :plan_id attr_accessible :name, :keyword validates_format_of :keyword, :with => %r{^[a-z0-9]+$}, :message => "must be only lower case letters." end module InstanceMethods def to_param keyword 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 def expired? trial? && past_trial? end def past_trial? created_at < 30.days.ago end end module ClassMethods def deliver_expiring_trial_notifications trial_expiring.each { |account| BillingMailer.expiring_trial(account).deliver } end def trial_expiring joins(:plan). where(:plans => { :trial => true }). where(:notified_of_expiration => false). where(["accounts.created_at <= ?", 23.days.ago]) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
saucy-0.2.31 | lib/saucy/account.rb |
saucy-0.2.30 | lib/saucy/account.rb |
saucy-0.2.29 | lib/saucy/account.rb |