码迷,mamicode.com
首页 > 其他好文 > 详细

rails datagrid easyui

时间:2014-06-29 20:19:48      阅读:437      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   os   cti   c   

  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

 

rails datagrid easyui,布布扣,bubuko.com

rails datagrid easyui

标签:style   blog   color   os   cti   c   

原文地址:http://www.cnblogs.com/yuzhengdong/p/3814785.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!