0
我是Rails的新手。在json响应中添加分页以包含方法
如何将分页添加到json中的方法?
我有如下一个show方法:
def show
respond_to do |format|
format.html { redirect_to @question, notice: 'Y'}
format.json {render json: @question.to_json(:include => { :responses => {:methods => [:description, :file_url] } })}
end
end
我想分页列入questions.to_json响应。我怎么做?
谢谢!
谢谢您的回复@Dnyanarth。我已经在使用kaminari宝石进行分页。我可以对问题进行分页,但我无法对问题中的回答进行分页。如何在代码中对包含在此行中的响应进行分页? format.json {render json:@ questions.to_json(:include => {:responses => {:methods => [:description,:file_url]}})} – Dharmil