Created
September 26, 2012 20:32
-
-
Save barelyknown/3790422 to your computer and use it in GitHub Desktop.
Decorator Modules
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
# This: | |
# <div name="#{@article.div_name"}> | |
# Instead of: | |
# <div name="<%= "#{@article.class.to_s.underscore}[#{@article.try(:id)}]"></div> | |
# What's the DRY way that you'd recommend to include this method (and other similar ideas) in every decorator? | |
def div_name | |
model_class.to_s.underscore + '[' + try(:id).to_s + ']' | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
oh. in Draper, you can just make an ApplicationDecorator. it should be inthe README.