Ext JS friendly JSON output using respond_with
Ruby
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.

README.textile

ExtJson

Output ExtJS 3.X friendly JSON using respond_with.

Setup

Install the plugin:
rails plugin install git://github.com/primary0/Ext-Json.git

In your environment.rb set “include_root_in_json” to “false”:
ActiveRecord::Base.include_root_in_json = false

Set the “root” attribute of your Ext Datasource to “data”.

Add the following to your controllers.
respond_to :json

Usage

Sample index method:
@posts = Post.all
respond_with @posts.ext_json

Sample output for the above method:
{"data" : [{"title" : "First Post"}, {"title" : "Second Post"}], "total":2}

2011 Mohamed Ashraf – MIT license