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:
@@ -8,6 +8,9 @@ require_relative "danbooru_local_config"
|
||||
|
||||
module Danbooru
|
||||
class Application < Rails::Application
|
||||
# Use the responders controller from the responders gem
|
||||
config.app_generators.scaffold_controller :responders_controller
|
||||
|
||||
# Initialize configuration defaults for originally generated Rails version.
|
||||
config.load_defaults 5.2
|
||||
config.active_record.schema_format = :sql
|
||||
|
||||
Reference in New Issue
Block a user