首页 > 代码库 > rails datagrid easyui
rails datagrid easyui
def new # @foo = Foo.new @foos = Foo.find(:all,:conditions=>["project_id = #{@project.id}"]) @foolist = @foos.map do |f| { :id => f.id, :subject => f.subject} end respond_to do |format| format.json { render :json => @foolist.to_json} end end
响应
[{"id":6,"subject":"test1-1"},{"id":7,"subject":"11221"},{"id":8,"subject":"1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"}]
改善
def test_json ActiveRecord::Base.include_root_in_json = false @foos = Foo.find(:all,:conditions=>["project_id = #{@project.id}"]) respond_to do |format| format.json { render :json => @foos} end end
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。