Sha256: d35b9bd4bc0659f65c02b0b7f01a6a3b88b50f22a11acd88488cf02cc4045377
Contents?: true
Size: 1.12 KB
Versions: 25
Compression:
Stored size: 1.12 KB
Contents
# == Schema Information # # Table name: wbase_subscriptions # # id :integer not null, primary key # stripe_id :string not null # plan_id :integer not null # last_four :string # coupon_id :integer # card_type :string # current_price :integer # user_id :integer not null # paid_thru :datetime # credit_card_token :string # created_at :datetime not null # updated_at :datetime not null # # Indexes # # index_wbase_subscriptions_on_plan_id (plan_id) # index_wbase_subscriptions_on_user_id (user_id) # module Wbase class Subscription < ActiveRecord::Base validates :user, :plan, :credit_card_token, presence: true belongs_to :plan belongs_to :user def self.current where('paid_thru > ?', 7.days.ago) end def current? paid_thru && paid_thru > 7.days.ago end def trial? created_at > 14.days.ago end def trial_days_left return 0 unless trial? (conversion_day.to_date - Date.current.to_date).to_i end end end
Version data entries
25 entries across 25 versions & 1 rubygems