From 9e91d26b1434bcf2c4151e74cdfc527bf50f0d95 Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Sun, 9 Dec 2018 08:54:42 +0500 Subject: [PATCH] Move custom configuration to "config/settings/" --- config/application.rb | 4 ++++ config/environments/production.rb | 2 +- config/initializers/action_mailer_smtp_settings.rb | 2 +- config/initializers/devise.rb | 2 +- config/initializers/sidekiq.rb | 4 ++-- config/{ => settings}/cache_store.yml | 0 config/{ => settings}/devise.yml | 0 config/{ => settings}/sidekiq_client.yml | 0 config/{ => settings}/sidekiq_server.yml | 0 config/{ => settings}/smtp.yml | 0 config/{ => settings}/superuser.yml | 0 db/seeds.rb | 2 +- 12 files changed, 10 insertions(+), 6 deletions(-) rename config/{ => settings}/cache_store.yml (100%) rename config/{ => settings}/devise.yml (100%) rename config/{ => settings}/sidekiq_client.yml (100%) rename config/{ => settings}/sidekiq_server.yml (100%) rename config/{ => settings}/smtp.yml (100%) rename config/{ => settings}/superuser.yml (100%) diff --git a/config/application.rb b/config/application.rb index df98ed8..1eb9767 100644 --- a/config/application.rb +++ b/config/application.rb @@ -30,6 +30,10 @@ module Partynest unlock_token ].freeze + def settings(name) + config_for "settings/#{name}" + end + # Initialize configuration defaults for originally generated Rails version. config.load_defaults 5.2 diff --git a/config/environments/production.rb b/config/environments/production.rb index 95129a2..b6d2b3b 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -65,7 +65,7 @@ Rails.application.configure do config.log_tags = [:request_id] # Use a different cache store in production. - cache_conf = Rails.application.config_for(:cache_store).deep_symbolize_keys + cache_conf = Rails.application.settings(:cache_store).deep_symbolize_keys config.cache_store = :redis_cache_store, { host: cache_conf[:host], port: cache_conf[:port], diff --git a/config/initializers/action_mailer_smtp_settings.rb b/config/initializers/action_mailer_smtp_settings.rb index bb8438c..d1a1cde 100644 --- a/config/initializers/action_mailer_smtp_settings.rb +++ b/config/initializers/action_mailer_smtp_settings.rb @@ -2,7 +2,7 @@ # Be sure to restart your server when you modify this file. -conf = Rails.application.config_for(:smtp).deep_symbolize_keys +conf = Rails.application.settings(:smtp).deep_symbolize_keys ActionMailer::Base.smtp_settings = { address: conf[:address], diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index d300f1d..3d02fc1 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -2,7 +2,7 @@ # Be sure to restart your server when you modify this file. -conf = Rails.application.config_for(:devise).deep_symbolize_keys +conf = Rails.application.settings(:devise).deep_symbolize_keys # Use this hook to configure devise mailer, warden hooks and so forth. # Many of these configuration options can be set straight in your model. diff --git a/config/initializers/sidekiq.rb b/config/initializers/sidekiq.rb index 8990486..56375a9 100644 --- a/config/initializers/sidekiq.rb +++ b/config/initializers/sidekiq.rb @@ -2,8 +2,8 @@ # Be sure to restart your server when you modify this file. -client_conf = Rails.application.config_for(:sidekiq_client).deep_symbolize_keys -server_conf = Rails.application.config_for(:sidekiq_server).deep_symbolize_keys +client_conf = Rails.application.settings(:sidekiq_client).deep_symbolize_keys +server_conf = Rails.application.settings(:sidekiq_server).deep_symbolize_keys Sidekiq.configure_client do |config| config.redis = { diff --git a/config/cache_store.yml b/config/settings/cache_store.yml similarity index 100% rename from config/cache_store.yml rename to config/settings/cache_store.yml diff --git a/config/devise.yml b/config/settings/devise.yml similarity index 100% rename from config/devise.yml rename to config/settings/devise.yml diff --git a/config/sidekiq_client.yml b/config/settings/sidekiq_client.yml similarity index 100% rename from config/sidekiq_client.yml rename to config/settings/sidekiq_client.yml diff --git a/config/sidekiq_server.yml b/config/settings/sidekiq_server.yml similarity index 100% rename from config/sidekiq_server.yml rename to config/settings/sidekiq_server.yml diff --git a/config/smtp.yml b/config/settings/smtp.yml similarity index 100% rename from config/smtp.yml rename to config/settings/smtp.yml diff --git a/config/superuser.yml b/config/settings/superuser.yml similarity index 100% rename from config/superuser.yml rename to config/settings/superuser.yml diff --git a/db/seeds.rb b/db/seeds.rb index 4c9c6d0..dea7b88 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -10,7 +10,7 @@ country_state_names.each do |name| CountryState.create! name: name end -Rails.application.config_for(:superuser).deep_symbolize_keys.tap do |config| +Rails.application.settings(:superuser).deep_symbolize_keys.tap do |config| User.where(email: config[:email]).first_or_create! do |new_user| new_user.account = Account.create! new_user.password = config[:password]