3ef5e4eeef
Before, we were relying on just changing the cards_count in account, but this could create problems where the system to calculate the next card number fails due to the unique constraint.
20 lines
352 B
Ruby
20 lines
352 B
Ruby
module Account::Billing
|
|
extend ActiveSupport::Concern
|
|
|
|
included do
|
|
has_one :subscription, class_name: "Account::Subscription", dependent: :destroy
|
|
end
|
|
|
|
def plan
|
|
active_subscription&.plan || Plan.free
|
|
end
|
|
|
|
def active_subscription
|
|
subscription if subscription&.active?
|
|
end
|
|
|
|
def subscribed?
|
|
subscription.present?
|
|
end
|
|
end
|