【发布时间】:2010-10-11 08:20:56
【问题描述】:
我很想使用render :json,但它似乎不够灵活。这样做的正确方法是什么?
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @things }
#This is great
format.json { render :text => @things.to_json(:include => :photos) }
#This doesn't include photos
format.json { render :json => @things, :include => :photos }
end
【问题讨论】:
标签: ruby-on-rails json api