Created
July 27, 2012 16:16
-
-
Save stevenbristol/3188943 to your computer and use it in GitHub Desktop.
overriding DecoratedEnumerableProxy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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