mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-03-24 09:43:24 -04:00
24 lines
533 B
Ruby
24 lines
533 B
Ruby
class Account < ApplicationRecord
|
|
belongs_to :member
|
|
belongs_to :account_type
|
|
|
|
validates :member_id, uniqueness: {
|
|
message: 'already has account details associated with it'
|
|
}
|
|
|
|
before_create do |account|
|
|
unless account.account_type
|
|
account.account_type = AccountType.find_or_create_by(name:
|
|
Rails.application.config.default_account_type)
|
|
end
|
|
end
|
|
|
|
def paid_until_string
|
|
if account_type.is_permanent_paid
|
|
"forever"
|
|
elsif account_type.is_paid
|
|
paid_until.to_s
|
|
end
|
|
end
|
|
end
|