mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-05-16 20:49:26 -04:00
27 lines
627 B
Ruby
27 lines
627 B
Ruby
class Account < ActiveRecord::Base
|
|
attr_accessible :account_type_id, :member_id, :paid_until
|
|
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(
|
|
Growstuff::Application.config.default_account_type
|
|
)
|
|
end
|
|
end
|
|
|
|
def paid_until_string
|
|
if account_type.is_permanent_paid
|
|
return "forever"
|
|
elsif account_type.is_paid
|
|
return paid_until.to_s
|
|
end
|
|
end
|
|
|
|
end
|