开发者

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 )

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜