在rails3中减少json响应

时间:2011-07-12 09:19:56

标签: json ruby-on-rails-3 view

我想让我的Rails3应用程序用json响应某些资产的请求。对于我的应用程序,发送与资产相关的所有信息是不合适的,但是,是否有某种方法来指定字段?我知道在Rails2中有一种方法。这是一些代码:

  def index
    @directories = Directory.all

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @directories }
      format.json { render :json => @directories }
    end
  end

1 个答案:

答案 0 :(得分:1)

答案有点过时,但我想它会起作用render :json does not accept options