-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathapplication.rb
More file actions
82 lines (64 loc) · 3.33 KB
/
application.rb
File metadata and controls
82 lines (64 loc) · 3.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
require_relative "boot"
require "rails/all"
require "./app/lib/hosting_environment"
require "./app/lib/json_log_formatter"
require "./app/lib/application_logger"
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module FormsAdmin
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 8.0
# Please, add to the `ignore` list any other `lib` subdirectories that do
# not contain `.rb` files, or that should not be reloaded or eager loaded.
# Common ones are `templates`, `generators`, or `middleware`, for example.
config.autoload_lib(ignore: %w[assets tasks warden generators notifications_utils])
# Configuration for the application, engines, and railties goes here.
#
# These settings can be overridden in specific environments using the files
# in config/environments, which are processed later.
#
# config.time_zone = "Central Time (US & Canada)"
# config.eager_load_paths << Rails.root.join("extras")
config.exceptions_app = routes
config.action_dispatch.rescue_responses["NotFoundError"] = :not_found
# All forms should use GOVUKDesignSystemFormBuilder by default
config.action_view.default_form_builder = GOVUKDesignSystemFormBuilder::FormBuilder
# Make it easier to share partials between controllers
config.action_view.prefix_partial_path_with_controller_namespace = false
config.view_component.previews.paths = [Rails.root.join("spec/components")]
config.view_component.previews.route = "/preview"
config.view_component.previews.controller = "ComponentPreviewController"
# Replace with value which will be true in local dev
config.view_component.show_previews = HostingEnvironment.test_environment?
### LOGGING CONFIGURATION ###
config.log_level = :info
# Lograge is used to format the standard HTTP request logging
config.lograge.enabled = true
config.lograge.formatter = Lograge::Formatters::Json.new
config.lograge.logger = ActiveSupport::Logger.new($stdout)
# Lograge suppresses the default Rails request logging. Set this to true to
# make lograge output it which includes some extra debugging
# information.
config.lograge.keep_original_rails_log = false
config.lograge.custom_options = lambda do |event|
CurrentLoggingAttributes.attributes.merge(
exception: event.payload[:exception],
queries_count: event.payload[:queries_count],
cached_queries_count: event.payload[:cached_queries_count],
).compact
end
# Use custom logger and formatter to log in JSON with request context fields. To use conventional
# logging use ActiveSupport::Logger.new($stdout).
config.logger = ApplicationLogger.new($stdout)
config.logger.formatter = JsonLogFormatter.new
# Prevent ActiveRecord::PreparedStatementCacheExpired errors when adding columns
config.active_record.enumerate_columns_in_select_statements = true
# Include full precision of timestamps in JSON responses
config.active_support.time_precision = 6
# Turn off locale enforcement - this allows us to use locales
# in Mobility without enabling those languages for the admin UI
I18n.enforce_available_locales = false
end
end