Figured it out.
Have to set ActiveRecord::Base.include_root_in_json = false
On Mar 5, 3:00 pm, skt <stibre...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Folks,
>
> I have a Meal model and Model.find(:all).to_json returns the following
>
> [{"meal": {"name": "Veggies Lasagna",
"id": 1}}, {"meal": {"name":
> "Chicken Rice", "id": 2}}, {"meal":
{"name": "Noodle Rice", "id": 3}}]
>
> What I want to do is not have the table name (meal) be part of the
> output json string i.e. what I want it to output is
>
> [ {"name": "Veggies Lasagna", "id": 1},
{"name": "Chicken Rice", "id":
> 2}, {"name": "Noodle Rice", "id": 3}]
>
> Any way I can do this? I looked at to_json input options which seem to
> let you control the columns that are output but apparently not the
> table name.
>
> If you are wondering why I need JSON output in this format, that is
> because I want to consume this output from dojo.data.ItemFileReadStore
>
> Thanks for any pointers/help.
>
> -S
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---