The documentation on to_json says that serialization outputs just the  
attributes hash as json from an AR record

http://api.rubyonrails.org/classes/ActiveRecord/Serialization.html#M001826

That suggests that if I did something like  
Account.find(:first).to_json I'd get something like

{"name": ...}

However I'm looking at several version of rails apps (2.2 and edge/ 
2.3) from the console and if I do something like  
Account.find(:first).to_json I get something more akin to

{"account": {"name" : ...}}

I'm not sure which one is right and which one is wrong.

It's also worth noting that if ActiveResource gets the second type as  
a response, it actually creates an incorrect Account object where  
attributes hash contains the proper Account object. ActiveResource  
appears to require the response listed in the documentation although I  
haven't seen that being generated.

Just a note, I removed all my JSON gems just in case there was some  
kind of conflict.

What's going on here, am I just overlooking something?

Josh Ferguson

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to