On Aug 13, 3:38 am, "w.d." <[email protected]> wrote:
> Hi Everyone,
>
> I am a Rails newbie. I got a minor question about the JSON format
> produced by to_json method.
>
> currently my code @events.to_json (:only =>
> [:id , :title, :start, :end]) will produce the output  :
>
> [{"event": {"title": "Dissect", "id": 996332877, "end":
> "2009-07-27T17:46:10Z", "start": "2009-07-27T15:46:10Z"}}, {"event":
> {"title": "Operation", "id": 953125641, "end": "2009-07-27T14:46:10Z",
> "start": "2009-07-27T12:46:10Z"}}]
>
> but I want the format of the JSON output like
>
> [{"title": "Dissect", "id": 996332877, "end": "2009-07-27T17:46:10Z",
> "start": "2009-07-27T15:46:10Z"},{"title": "Operation", "id":
> 953125641, "end": "2009-07-27T14:46:10Z", "start":
> "2009-07-27T12:46:10Z"}]
>
> how can I remove the unnecessary "event" atttribute?

If you look in the new_rails_defaults.yml file there is a setting that
controls this.

Fred
>
> Any help will be greatly appreciated
>
> Regards,
>
> w.d.
--~--~---------~--~----~------------~-------~--~----~
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 [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-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to