You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
940 B
Ruby
37 lines
940 B
Ruby
class ApplicationDecorator < Draper::Base
|
|
# Lazy Helpers
|
|
# PRO: Call Rails helpers without the h. proxy
|
|
# ex: number_to_currency(model.price)
|
|
# CON: Add a bazillion methods into your decorator's namespace
|
|
# and probably sacrifice performance/memory
|
|
#
|
|
# Enable them by uncommenting this line:
|
|
# lazy_helpers
|
|
|
|
# Shared Decorations
|
|
# Consider defining shared methods common to all your models.
|
|
#
|
|
# Example: standardize the formatting of timestamps
|
|
#
|
|
# def formatted_timestamp(time)
|
|
# h.content_tag :span, time.strftime("%a %m/%d/%y"),
|
|
# :class => 'timestamp'
|
|
# end
|
|
#
|
|
# def created_at
|
|
# formatted_timestamp(model.created_at)
|
|
# end
|
|
#
|
|
# def updated_at
|
|
# formatted_timestamp(model.updated_at)
|
|
# end
|
|
|
|
def as_json(*args)
|
|
model.as_json(*args)
|
|
end
|
|
|
|
def markdown(text)
|
|
MKD_SAFE_RENDERER.render(text).html_safe
|
|
end
|
|
end
|