class ActionController::Responder

def api_behavior

This is the common behavior for formats associated with APIs, such as :xml and :json.
def api_behavior
  raise MissingRenderer.new(format) unless has_renderer?
  if get?
    display resource
  elsif post?
    display resource, status: :created, location: api_location
  else
    head :no_content
  end
end