Skip to content

Commit 5087a85

Browse files
authored
Merge pull request rails#55347 from bensheldon/activemodel-load-hooks
Add load-hooks for Active Model autoloaded constants referenced in initializers
2 parents b8fb0ce + af42a44 commit 5087a85

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

activemodel/lib/active_model/error.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,4 +204,6 @@ def attributes_for_hash
204204
[@base, @attribute, @raw_type, @options.except(*CALLBACKS_OPTIONS)]
205205
end
206206
end
207+
208+
ActiveSupport.run_load_hooks(:active_model_error, Error)
207209
end

activemodel/lib/active_model/railtie.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,15 @@ class Railtie < Rails::Railtie # :nodoc:
1414
end
1515

1616
initializer "active_model.secure_password" do
17-
ActiveModel::SecurePassword.min_cost = Rails.env.test?
17+
ActiveSupport.on_load(:active_model_secure_password) do
18+
ActiveModel::SecurePassword.min_cost = Rails.env.test?
19+
end
1820
end
1921

20-
initializer "active_model.i18n_customize_full_message" do
21-
ActiveModel::Error.i18n_customize_full_message = config.active_model.delete(:i18n_customize_full_message) || false
22+
initializer "active_model.i18n_customize_full_message" do |app|
23+
ActiveSupport.on_load(:active_model_error) do
24+
ActiveModel::Error.i18n_customize_full_message = app.config.active_model.i18n_customize_full_message || false
25+
end
2226
end
2327
end
2428
end

activemodel/lib/active_model/secure_password.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,4 +228,6 @@ def initialize(attribute, reset_token:)
228228
end
229229
end
230230
end
231+
232+
ActiveSupport.run_load_hooks(:active_model_secure_password, SecurePassword)
231233
end

0 commit comments

Comments
 (0)