class Invoice < ActiveRecord::Base belongs_to :invoice_type has_many :invoice_items has_many :invoice_party_roles has_many :parties, :through => :invoice_party_roles #This line of code connects the invoice to a polymorphic payment application. #The effect of this is to allow payments to be "applied_to" invoices has_many :payment_applications, :as => :payment_applied_to alias :items :invoice_items alias :type :invoice_type alias :party_roles :invoice_party_roles end