Skip to content

Instantly share code, notes, and snippets.

@xhoy
Last active June 27, 2016 07:57
Show Gist options
  • Save xhoy/6712a257df383093e1f06a15033677b4 to your computer and use it in GitHub Desktop.
Save xhoy/6712a257df383093e1f06a15033677b4 to your computer and use it in GitHub Desktop.
app/models/invoice_payment.rb
class InvoicePayment < ActiveRecord::Base
def to_liquid
InvoicePaymentDrop.new(self)
end
end
app/drops/invoice_payment_drop.rb
class InvoicePaymentDrop < Liquid::Drop
delegate :days_late, :duedate, :priceinbtw, :priceexbtw, :print_date, :id, :late, :unpayed, to: :invoice
attr_reader :invoice
def initialize(invoice)
@invoice = invoice
end
end
console:
>> reload!;InvoicePayment.last.to_liquid
NameError: uninitialized constant InvoicePayment::InvoicePaymentDrop
####
class Invoice < ActiveRecord::Base
def to_liquid
InvoiceDrop.new(self)
end
end
class InvoiceDrop < Liquid::Drop
delegate :days_late, :duedate, :priceinbtw, :priceexbtw, :print_date, :id, :late, :unpayed, to: :invoice
attr_reader :invoice
def initialize(invoice)
@invoice = invoice
end
end
console:
>> reload!;Invoice.last.to_liquid
InvoiceDrop
class Invoice < ActiveRecord::Base
def to_liquid
InvoiceDrop.new(self)
end
end
class InvoicePayment < ActiveRecord::Base
def to_liquid
InvoicePaymentDrop.new(self)
end
end
Class InvoiceDropZ < Liquid::Drop #TYPO Z
delegate :days_late, :duedate, :priceinbtw, :priceexbtw, :print_date, :id, :late, :unpayed, to: :invoice
attr_reader :invoice
def initialize(invoice)
@invoice = invoice
end
end
class InvoicePaymentDropZ < Liquid::Drop #TYPO Z
delegate :id, :invoice_id, :amount, :description, :payment_type, :created_at, :updated_at, :user_id, to: :invoice_payment
attr_reader :invoice_payment
def initialize(invoice_payment)
@invoice_payment = invoice_payment
end
end
###
>> reload!;Invoice.last.to_liquid
Reloading...
Invoice Load (0.2ms) SELECT `invoices`.* FROM `invoices` ORDER BY `invoices`.`id` DESC LIMIT 1
LoadError: Unable to autoload constant InvoiceDrop, expected /home/thowou/rubyprojects/finance-dev/app/drops/invoice_drop.rb to define it
>> reload!;InvoicePayment.last.to_liquid
Reloading...
InvoicePayment Load (0.2ms) SELECT `invoice_payments`.* FROM `invoice_payments` ORDER BY `invoice_payments`.`id` DESC LIMIT 1
NameError: uninitialized constant InvoicePayment::InvoicePaymentDrop
class InvoicePayment < ActiveRecord::Base #lowercase
def to_liquid
InvoicepaymentDrop.new(self)
end
end
>> reload!;InvoicePayment.last.to_liquid
Reloading...
InvoicePayment Load (0.2ms) SELECT `invoice_payments`.* FROM `invoice_payments` ORDER BY `invoice_payments`.`id` DESC LIMIT 1
LoadError: Unable to autoload constant InvoicepaymentDrop, expected /home/thowou/rubyprojects/finance-dev/app/drops/invoicepayment_drop.rb to define it
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment