Sha256: 1ef0e98d409e394b2bc6c0a1f4d0fe57eb95871cf755e3cabc23d1f115b9327b

Contents?: true

Size: 729 Bytes

Versions: 7

Compression:

Stored size: 729 Bytes

Contents

class MembershipType < ActiveRecord::Base
  attr_accessible :name, :price, :fee, :number_of_shows, :plan, :on_sale, :description, :ends_at, :starts_at

  belongs_to :organization
  has_many :memberships
  has_many :members, :through => :memberships
  belongs_to :segment

  after_create :create_list_segment
  
  default_scope order("created_at DESC")
  scope :on_sale, where(:on_sale => true)

  def membershipize
    self.name.end_with?("Membership") ? self.name : self.name + " Membership"
  end

  def create_list_segment
    @search = organization.searches.create({:membership_type => self})
    @segment = organization.segments.create({:search => @search, :name => self.name})
    self.segment = @segment
    save
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
artfully_ose-1.2.0.pre.6 app/models/membership_type.rb
artfully_ose-1.2.0.pre.5 app/models/membership_type.rb
artfully_ose-1.2.0.pre.4 app/models/membership_type.rb
artfully_ose-1.2.0.pre.3 app/models/membership_type.rb
artfully_ose-1.2.0.pre.2 app/models/membership_type.rb
artfully_ose-1.2.0.pre.1 app/models/membership_type.rb
artfully_ose-1.2.0.pre app/models/membership_type.rb