That's not technically true, you can include associations in the output:

respond_to do |wants|
   wants.json {  render :text => @object.to_json(:include =>  
[:assocation1, :association2]) }
end

Something like Jester (http://jesterjs.org) handles this nicely.

-Blake

On Aug 28, 2008, at 6:41 AM, Aaron Spiegel wrote:

>
> Last I looked into it, the JSON reponse object returns the the raw
> related object.  For instance in the "list" action the JSON array will
> contain all the local attributes but doesn't pay attention to your
> "columns" configuration or associations.
>
> My solution was to monkey patch the actions changing the JSON format
> to render a template:
>
> http://github.com/spiegela/active_scaffold_extjs_sample_app/tree/master/lib/extjs_actions.rb
>
> And then create .json.erb templates:
>
> http://github.com/spiegela/active_scaffold_extjs_sample_app/tree/master/vendor/plugins/active_scaffold/frontends/extjs/views/list.json.erb
>
> http://github.com/spiegela/active_scaffold_extjs_sample_app/tree/master/vendor/plugins/active_scaffold/frontends/extjs/views/_list_record.json.erb
>
> HTH,
> Aaron
>
> On Thu, Aug 28, 2008 at 12:26 AM, glennswest  
> <[EMAIL PROTECTED]> wrote:
>>
>> Hi guys
>>
>> I'm writing a ruby client application that needs to pull data
>> programatically from a rails/AS app, for a table.
>>
>> At startup it really needs to pull a "large" chunk of the "data",
>> least for id, and one field, if not the whole table. (At this all
>> columns are fine, but due to perfomance, be nice just to request
>> "minimal" data.
>>
>> I see that "JSON" is baked in references, but do not see a single
>> client "example" or any special route or configuration that is  
>> needed.
>>
>> Is it really "baked" In?
>> Anyone got a example of "reading" a model via json?
>> Adding a "record" via json?
>> Adding a "group" of records via json?
>>
>>
>>>
>>
>
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"ActiveScaffold : Ruby on Rails plugin" 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/activescaffold?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to