/examples/singleview/payment_invoice.rb

https://github.com/drnic/magic_model_generator · Ruby · 17 lines · 17 code · 0 blank · 0 comment · 0 complexity · 63ff128ac0f20bf1011955bfa568f3d5 MD5 · raw file

  1. class PaymentInvoice < ActiveRecord::Base
  2. belongs_to :payment, :class_name => 'Payment', :foreign_key => :payment_id
  3. belongs_to :account, :class_name => 'Account', :foreign_key => :account_id
  4. belongs_to :invoice, :class_name => 'Invoice', :foreign_key => :invoice_id
  5. belongs_to :receivable_type, :class_name => 'ReceivableType', :foreign_key => :receivable_type_id
  6. validates_presence_of :payment_id
  7. validates_numericality_of :payment_id, :allow_nil => false, :only_integer => true
  8. validates_presence_of :account_id
  9. validates_numericality_of :account_id, :allow_nil => false, :only_integer => true
  10. validates_presence_of :seqnr
  11. validates_numericality_of :seqnr, :allow_nil => false, :only_integer => true
  12. validates_presence_of :last_modified
  13. validates_numericality_of :invoice_id, :allow_nil => true, :only_integer => true
  14. validates_numericality_of :receivable_type_id, :allow_nil => true, :only_integer => true
  15. validates_presence_of :amount
  16. validates_numericality_of :amount, :allow_nil => false
  17. end