Skip to content
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

Render JSON with root false #66

Closed
yujingz opened this issue Nov 5, 2012 · 2 comments
Closed

Render JSON with root false #66

yujingz opened this issue Nov 5, 2012 · 2 comments

Comments

@yujingz
Copy link

yujingz commented Nov 5, 2012

Hi,

Thank you for your awesome gem, I'm using this to glue my backbone.js code with rails.

One thing I want to know is, in default rails, I can do things like this

user = User.find(xx)
user.to_json(:root => false)

to get rid of some nested key name. But now, after adapted gon, it automatically help me finished the covert between rails object and json. Therefore I don't have a place to do the render with root false.

@yujingz
Copy link
Author

yujingz commented Nov 5, 2012

What now I am doing is like this

gon.myVar = user.to_json(:root =>false)

and in js side

myVar = JSON.parse(gon.myVar)

I can stand with this but it's great if gon can support this kind of feature.

@yujingz yujingz closed this as completed Nov 5, 2012
@yujingz yujingz reopened this Nov 5, 2012
@yujingz
Copy link
Author

yujingz commented Nov 7, 2012

Perfectly solved this by adopting rabl. Sorry for my ignorance.

@yujingz yujingz closed this as completed Nov 7, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant