Open-Source-Access-Control-.../app/models/payment.rb

18 lines
447 B
Ruby
Raw Normal View History

2013-02-12 08:58:17 +00:00
class Payment < ActiveRecord::Base
belongs_to :user
2013-08-24 09:18:37 +00:00
has_one :ipn
attr_accessible :date, :user_id, :created_by, :amount
2013-02-12 08:58:17 +00:00
2013-08-24 09:18:37 +00:00
validates_presence_of :user_id, :date, :amount # not created_by
2013-02-12 08:58:17 +00:00
validates_uniqueness_of :date, :scope => :user_id, :message => ' of payment already exists for this user.'
2013-08-24 09:18:37 +00:00
2013-02-12 08:58:17 +00:00
def human_date
if date.year < DateTime.now.year
date.strftime("%b %e, %y")
else
date.strftime("%b %e")
end
end
end