I think you can do something like this...

@booking.to_json(:only=>["title","id","start","end","url"])

On May 6, 10:13 am, lyntaff <[email protected]> wrote:
> I'm really new to rendering formats with rails and would appreciate a
> little help with a json issue.
>
> I have created a booking model in which I would like to sync with a
> jquery calendar called "full calendar" through json. They have an
> example json script output with the following:
>
> [
>    {
>       "id":1,
>       "title":"Event1",
>       "start":"2009-05-10",
>    },
>    {
>       "id":2,
>       "title":"Event2",
>       "start":"2009-05-20",
>       "end":"2009-05-22",
>       "url":"http:\/\/yahoo.com\/"
>    }
> ]
>
> When using the json format in rails I get:
>
> [
>    {
>       "booking":{
>          "updated_at":"2009-05-01T15:42:44Z",
>          "title":"Booking",
>          "property_id":1,
>          "id":1,
>          "end":"2009-05-19",
>          "start":"2009-05-06",
>          "created_at":"2009-05-01T15:42:44Z"
>       }
>    },
>    {
>       "booking":{
>          "updated_at":"2009-05-06T09:09:48Z",
>          "title":"Booking",
>          "property_id":1,
>          "id":2,
>          "end":"2009-08-26",
>          "start":"2009-08-19",
>          "created_at":"2009-05-06T09:09:48Z"
>       }
>    }
> ]
>
> How do I change how the json format is rendered within rails 2. I need
> to get rid of "booking", "updated_at", property_id" and created_at".
>
> Thanks for any help.
--~--~---------~--~----~------------~-------~--~----~
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