Skip to content

Instantly share code, notes, and snippets.

@barelyknown
Created September 26, 2012 20:32
Show Gist options
  • Save barelyknown/3790422 to your computer and use it in GitHub Desktop.
Save barelyknown/3790422 to your computer and use it in GitHub Desktop.
Decorator Modules
# 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
@steveklabnik
Copy link

oh. in Draper, you can just make an ApplicationDecorator. it should be inthe README.

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