0.0
No commit activity in last 3 years
No release in over 3 years
Rails 3 Renderer for JSON compatible with Sencha Extjs 3+
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

> 3.0.0
 Project Readme

ExtjsRenderer

Rails 3 Renderer to send JSON compatible with Sencha Extjs 3+

Usage

ActiveRecord Relations

JSON root defaults to resource:

Controller action:

def index
	@items = Item.order('name')
	respond_with @items do |format|
		format.json { render :extjs => @items }
	end
end

Output:

{"total":1,"item":[{"id":1,"name":"widget"}]}

Custom JSON root and to_json params:

Controller action:

def index
	@items = Item.order('name')
	respond_with @items do |format|
		format.json { render :extjs => @items, :root => "product", :only => [:name], :methods => [:custom] }
	end
end

Or

def index
	@items = Item.order('name')
	respond_with @items do |format|
		format.json { render :extjs => @items, :root => "product", :except => [:id], :methods => [:custom] }
	end
end

Output:

{"total":1,"product":[{"name":"widget","custom":"custom method output"}]}

Single Resource

Root defaults to 'data' or :root => 'custom':

Controller action:

	def edit
		@item = Item.find(params[:id])
		respond_with @items do |format|
			format.json { render :extjs => @item, :only => [:name], :methods => [:custom] }
		end
	end

Output:

{"success":true,"data":[{"name":"widget","custom":"custom method output"}]}