Rails Object Relationships and JSON Rendering
By default you’ll only get the JSON that represents modelb in your example above. But, you can tell Rails to include the other related objects as well: def export @export_data = ModelA.find(params[:id]) respond_to do |format| format.html format.json { render :json => @export_data.to_json(:include => :modelb) } end end You can even tell it to exclude certain … Read more