Method: Entangled::Model::InstanceMethods#as_json

Defined in:
lib/entangled/model.rb

#as_json(options = nil) ⇒ Object

Override the as_json method so that the JSON representation of the resource includes its errors. This is necessary so that errors are sent back to the client along with the resource on create and update. Furthermore, keys are converted to camel case, to comply with JavaScript conventions on the client



74
75
76
77
# File 'lib/entangled/model.rb', line 74

def as_json(options = nil)
  super(options || attributes).merge(errors: errors).as_json.
    to_camelback_keys
end