Rails automatically calls to_json

as_json is implemented in the model to tell Rails what the
json represendation of a model is. ActiveRecord::Base includes
a default as_json.

to_json calls as_json when the models is being rendered by the controller.