Last active
August 29, 2015 14:17
-
-
Save skuroki/f6184db0f0e66bc0fa64 to your computer and use it in GitHub Desktop.
ActiveDecoratorでdecorateしたオブジェクトのhas_one/belong_to先のオブジェクトが自動でdecorateされるようにする ref: http://qiita.com/skuroki@github/items/087e0953583d259738a5
This file contains 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
module AssociationDecorator | |
def reader(*args) | |
result = super | |
if self.owner.is_a?(ActiveDecorator::Helpers) | |
ActiveDecorator::Decorator.instance.decorate(result) | |
end | |
result | |
end | |
end | |
module ActiveRecord | |
module Associations | |
class SingularAssociation | |
prepend AssociationDecorator | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment