1 require_relative "boot"
3 # Guard against deployments with old-style application.yml configurations
4 # Otherwise, admins might not be aware that they are now silently ignored
5 # and major problems could occur
6 # rubocop:disable Rails/Output, Rails/Exit
7 if File.exist?(File.expand_path("application.yml", __dir__))
8 puts "The config/application.yml file is no longer supported"
9 puts "Default settings are now found in config/settings.yml and you can override these in config/settings.local.yml"
10 puts "To prevent unexpected behaviour, please copy any custom settings to config/settings.local.yml"
11 puts " and then remove your config/application.yml file."
14 # rubocop:enable Rails/Output, Rails/Exit
16 if ENV["OPENSTREETMAP_STATUS"] == "database_offline"
17 require "active_model/railtie"
18 require "active_job/railtie"
19 require "active_storage/engine"
20 require "action_controller/railtie"
21 require "action_mailer/railtie"
22 require "action_view/railtie"
23 require "action_cable/engine"
24 require "sprockets/railtie"
25 require "rails/test_unit/railtie"
30 # Require the gems listed in Gemfile, including any gems
31 # you've limited to :test, :development, or :production.
32 Bundler.require(*Rails.groups)
35 class Application < Rails::Application
36 # Initialize configuration defaults for originally generated Rails version.
37 config.load_defaults 5.2
39 # Settings in config/environments/* take precedence over those specified here.
40 # Application configuration can go into files in config/initializers
41 # -- all .rb files in that directory are automatically loaded after loading
42 # the framework and any gems in your application.
44 # Custom directories with classes and modules you want to be autoloadable.
45 config.autoload_paths += %W[#{config.root}/lib]
47 # This defaults to true from rails 5.0 but our code doesn't comply
48 # with it at all so we turn it off
49 config.active_record.belongs_to_required_by_default = false unless Settings.status == "database_offline"
51 # Use SQL instead of Active Record's schema dumper when creating the database.
52 # This is necessary if your schema can't be completely dumped by the schema dumper,
53 # like if you have constraints or database-specific column types
54 config.active_record.schema_format = :sql unless Settings.status == "database_offline"
56 # Don't eager load models when the database is offline
57 config.paths["app/models"].skip_eager_load! if Settings.status == "database_offline"
59 # Use memcached for caching if required
60 config.cache_store = :mem_cache_store, Settings.memcache_servers, { :namespace => "rails:cache" } if Settings.key?(:memcache_servers)
62 # Use logstash for logging if required
63 if Settings.key?(:logstash_path)
64 config.logstasher.enabled = true
65 config.logstasher.suppress_app_log = false
66 config.logstasher.logger_path = Settings.logstash_path
67 config.logstasher.log_controller_parameters = true