-
Notifications
You must be signed in to change notification settings - Fork 527
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Decorated attributes inaccessible in to_json #97
Comments
Yes, because your calling article's class ArticleDecorator < ApplicationDecorator
decorates :article
def title
"hello world"
end
def as_json(*args)
{
:title => title
}
end
end a = ArticleDecorator.first
a.title # => "hello world"
a.to_json # => '{"title": "hello world"}' |
That explains it, thanks. |
Thanks, this helped me as well! |
This was helpful. Thanks. It would be nice to have a to_json method for decorators that merged the decorator and active record objects so that you could use to_json shortcuts to build the hash. |
Any and all feature suggestions welcome as pull requests. ;) however, you may want to check out https://github.com/josevalim/active_model_serializers |
Hello, thanks for outstanding work on draper. I'm having a small issue:
Background:
Problem:
Am I doing this wrong?
The text was updated successfully, but these errors were encountered: