alert('New object id: ' + <%= @user.id %>);
respond_to do |format| format.html # index.html.erb format.json { render :json => @things.to_json(:include => { :photos => { :only => [:id, :url] } }) } end
class Things < ActiveRecord::Base def as_json(options={}) super(options || include: :photos, only: [:id, :url])#1.9 hash end end #然后controller就可以直接用 render :json => @things