Skip to content

Instantly share code, notes, and snippets.

@jcasimir
Forked from stevenbristol/gist:3188943
Created July 27, 2012 22:48
Show Gist options
  • Save jcasimir/3190890 to your computer and use it in GitHub Desktop.
Save jcasimir/3190890 to your computer and use it in GitHub Desktop.
overriding DecoratedEnumerableProxy
class InvoicesController < ApplicationController
def index
respond_with id InvoicesDecorator.new(invoices, InvoiceDecorator)
end
end
class InvoicesDecorator < Draper::DecoratedEnumerableProxy
def method_regardless_of_invoices_empty_or_not
"yay"
end
end
class InvoiceDecorator < ApplicationDecorator
decorates :invoice
#normal stuffs
end
#index.html.haml
#invoices
= invoices.method_regardless_of_invoices_empty_or_not
- invoices.each do |invoice|
= invoice.amount
@jcasimir
Copy link
Author

Yeah, that makes sense to me. It's been awhile since I looked at the DecoratedEnumerableProxy though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment