How to add values to self.to_json
Right now, if I have a user object like @user.
I can do @user.to_json
What I want to do is add values to the json object rails creates. I've tried this:
@user.attributes.merge{ :catalyst_show => true }
But that errors with syntax error, unexpected tASSOC, expec开发者_JAVA技巧ting '}'
Any ideas on how you can add attributes to the json object?
thanks
you need to add parenthesis. @user.attributes.merge({ :catalyst_show => true }) or @user.attributes.merge( :catalyst_show => true )
精彩评论