@@ -87,17 +87,17 @@ class Railtie < Rails::Railtie # :nodoc:
87
87
end
88
88
89
89
initializer "active_record.migration_error" do |app |
90
- if config . active_record . delete ( : migration_error) == :page_load
90
+ if config . active_record . migration_error == :page_load
91
91
config . app_middleware . insert_after ::ActionDispatch ::Callbacks ,
92
92
ActiveRecord ::Migration ::CheckPending ,
93
93
file_watcher : app . config . file_watcher
94
94
end
95
95
end
96
96
97
97
initializer "active_record.database_selector" do
98
- if options = config . active_record . delete ( : database_selector)
99
- resolver = config . active_record . delete ( : database_resolver)
100
- operations = config . active_record . delete ( : database_resolver_context)
98
+ if options = config . active_record . database_selector
99
+ resolver = config . active_record . database_resolver
100
+ operations = config . active_record . database_resolver_context
101
101
config . app_middleware . use ActiveRecord ::Middleware ::DatabaseSelector , resolver , operations , options
102
102
end
103
103
end
@@ -128,9 +128,9 @@ class Railtie < Rails::Railtie # :nodoc:
128
128
end
129
129
130
130
initializer "active_record.check_schema_cache_dump" do
131
- check_schema_cache_dump_version = config . active_record . delete ( : check_schema_cache_dump_version)
131
+ check_schema_cache_dump_version = config . active_record . check_schema_cache_dump_version
132
132
133
- if config . active_record . delete ( : use_schema_cache_dump)
133
+ if config . active_record . use_schema_cache_dump
134
134
config . after_initialize do |app |
135
135
ActiveSupport . on_load ( :active_record ) do
136
136
db_config = ActiveRecord ::Base . configurations . configs_for ( env_name : Rails . env ) . first
@@ -205,15 +205,15 @@ class Railtie < Rails::Railtie # :nodoc:
205
205
SQLITE3_PRODUCTION_WARN = "You are running SQLite in production, this is generally not recommended." \
206
206
" You can disable this warning by setting \" config.active_record.sqlite3_production_warning=false\" ."
207
207
initializer "active_record.sqlite3_production_warning" do
208
- if config . active_record . delete ( : sqlite3_production_warning) && Rails . env . production?
208
+ if config . active_record . sqlite3_production_warning && Rails . env . production?
209
209
ActiveSupport . on_load ( :active_record_sqlite3adapter ) do
210
210
Rails . logger . warn ( SQLITE3_PRODUCTION_WARN )
211
211
end
212
212
end
213
213
end
214
214
215
215
initializer "active_record.set_configs" do |app |
216
- configs = app . config . active_record . except ( :query_log_tags_enabled , :query_log_tags , :cache_query_log_tags )
216
+ configs = app . config . active_record
217
217
218
218
config . after_initialize do
219
219
configs . each do |k , v |
@@ -226,6 +226,20 @@ class Railtie < Rails::Railtie # :nodoc:
226
226
end
227
227
228
228
ActiveSupport . on_load ( :active_record ) do
229
+ # Configs used in other initializers
230
+ configs = configs . except (
231
+ :migration_error ,
232
+ :database_selector ,
233
+ :database_resolver ,
234
+ :database_resolver_context ,
235
+ :query_log_tags_enabled ,
236
+ :query_log_tags ,
237
+ :cache_query_log_tags ,
238
+ :sqlite3_production_warning ,
239
+ :check_schema_cache_dump_version ,
240
+ :use_schema_cache_dump
241
+ )
242
+
229
243
configs . each do |k , v |
230
244
next if k == :encryption
231
245
setter = "#{ k } ="
0 commit comments