Skip to content

Instantly share code, notes, and snippets.

@stevenbristol
Created July 27, 2012 16:16
Show Gist options
  • Save stevenbristol/3188943 to your computer and use it in GitHub Desktop.
Save stevenbristol/3188943 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment