At the end of a standard Rails controller there is:
respond_to do |format| format.html format.json { render json: @cars } end
Works as expected. Except the JSON doesn't have the associations of @cars
:
class Car < ActiveRecord::Base attr_accessible :model, :color belongs_to :manufacturer end
The JSON doesn't have the fields of the manufacturer. How do I get the JSON to have those? Is there something I add to the belongs_to
call? Is there a way I can add it to the object created from format.json
?