From 978ca2667b41b6f5f5533146df8f939aa0e6f511 Mon Sep 17 00:00:00 2001 From: Alexia McDonald Date: Fri, 10 Sep 2021 20:41:08 +0200 Subject: [PATCH 1/3] Configurate to use API server --- config/application.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/application.rb b/config/application.rb index 4ecf5c5253..44c5a6a98d 100644 --- a/config/application.rb +++ b/config/application.rb @@ -10,6 +10,8 @@ module Ifme class Application < Rails::Application + # Configuration needed for changing an existing Rails app to API server + config.api_only = true # Initialize configuration defaults for originally generated Rails version. config.load_defaults 6.0 From 40f7f7249ee29ca20c7f65b880627ed715336c1f Mon Sep 17 00:00:00 2001 From: Alexia McDonald Date: Fri, 10 Sep 2021 20:46:05 +0200 Subject: [PATCH 2/3] Explicitly state debug exception response to api format" " --- config/environments/development.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/config/environments/development.rb b/config/environments/development.rb index a7c4e64b82..fdf767724b 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -86,4 +86,10 @@ config.action_controller.default_url_options = { host: primary_domain } config.action_controller.asset_host = primary_domain + + # To render an HTML page with debugging information, use the value :default. + # To render debugging information preserving the response format, use the value :api. + # By default, config.debug_exception_response_format is set to :api, when config.api_only is set to true. + # But we set it here explicitly so that we can change it if we want and we know that it is on. + config.debug_exception_response_format = :api end From cf7908501bf063aa0ab4fc55f62366b153e276cb Mon Sep 17 00:00:00 2001 From: Alexia McDonald Date: Fri, 10 Sep 2021 20:49:44 +0200 Subject: [PATCH 3/3] Change ApplicationController to use API instead of Base --- app/controllers/application_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 5e992f32a3..162975a831 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -class ApplicationController < ActionController::Base +class ApplicationController < ActionController::API include ActionView::Helpers::UrlHelper include ActionView::Helpers::DateHelper include ActionView::Helpers::TextHelper