gravier_app/app/models/tr_payment.rb
2017-09-21 12:37:53 +02:00

24 lines
482 B
Ruby

class TrPayment < ActiveRecord::Base
belongs_to :donator_transaction
belongs_to :tr_payment_type
belongs_to :tr_payment_bank_account
before_validation do
self.verify
self.iban = self.iban.to_s.gsub(/\s+/, "")
end
protected
def verify(size=16)
if !self.token
s = ""
size.times { s << (i = Kernel.rand(62); i += ((i < 10) ? 48 : ((i < 36) ? 55 : 61 ))).chr }
self.token = s
end
end
end