api: refactor default options for xml responses.
In xml responses, if the result is an empty array we want the response to look like this: <posts type="array"/> not like this (the default): <nil-classes type="array"/> This refactors controllers so that this is done automatically instead of having to manually call `@things.to_xml(root: "things")` everywhere. We do this by overriding the behavior of `respond_with` in `ApplicationResponder` to set the `root` option by default in xml responses.
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
class ApplicationController < ActionController::Base
|
||||
class ApiLimitError < StandardError; end
|
||||
|
||||
self.responder = ApplicationResponder
|
||||
|
||||
skip_forgery_protection if: -> { SessionLoader.new(request).has_api_authentication? }
|
||||
before_action :reset_current_user
|
||||
before_action :set_current_user
|
||||
|
||||
Reference in New Issue
Block a user