jsonapi-suite / jsonapi_compliable

MIT License
20 stars 35 forks source link

Hook up writes to 1.0 API #117

Closed richmolj closed 6 years ago

richmolj commented 6 years ago

There is still refactoring of internals to do, particularly around the proxies/runner, but this adds 1.0 support for writes:

def create
  employee = EmployeeResource.build(params)

  if employee.save
    render jsonapi: employee
  else
    render jsonapi_errors: employee
  end
end

def update
  employee = EmployeeResource.find(params)

  if employee.update_attributes
    render jsonapi: employee
  else
    render jsonapi_errors: employee
  end
end

def destroy
  employee = EmployeeResource.find(params)

  if employee.destroy
    render jsonapi: employee
  else
    render jsonapi_errors: employee
  end
end

This will honor the attribute types, see spec/persistence_spec.rb for detailed usage.

Questions:

Other notes:

richmolj commented 6 years ago

@wadetandy