aboutsummaryrefslogtreecommitdiffstats
path: root/activestorage
diff options
context:
space:
mode:
authorGeorge Claghorn <george.claghorn@gmail.com>2017-08-07 13:11:10 -0400
committerGeorge Claghorn <george.claghorn@gmail.com>2017-08-08 14:56:27 -0400
commitcaf7e623017311c3b857ab84402e1baa9bfba4f4 (patch)
tree62242379874d8e17fdfff0f3703aa05f9f0d3a2c /activestorage
parent4b72bee47bb590efac498ad2494efa769350aabd (diff)
downloadrails-caf7e623017311c3b857ab84402e1baa9bfba4f4.tar.gz
rails-caf7e623017311c3b857ab84402e1baa9bfba4f4.tar.bz2
rails-caf7e623017311c3b857ab84402e1baa9bfba4f4.zip
Set ActiveStorage::Blob.service when ActiveStorage::Blob is loaded
Fixes that ActiveStorage::Blob.service is unset when ActiveStorage::Blob is reloaded.
Diffstat (limited to 'activestorage')
-rw-r--r--activestorage/lib/active_storage/engine.rb31
1 files changed, 15 insertions, 16 deletions
diff --git a/activestorage/lib/active_storage/engine.rb b/activestorage/lib/active_storage/engine.rb
index da83d3908a..d5bc70fc0c 100644
--- a/activestorage/lib/active_storage/engine.rb
+++ b/activestorage/lib/active_storage/engine.rb
@@ -34,22 +34,21 @@ module ActiveStorage
end
initializer "active_storage.services" do
- config.after_initialize do |app|
- if config_choice = app.config.active_storage.service
- config_file = Pathname.new(Rails.root.join("config/storage.yml"))
- raise("Couldn't find Active Storage configuration in #{config_file}") unless config_file.exist?
-
- require "yaml"
- require "erb"
-
- configs =
- begin
- YAML.load(ERB.new(config_file.read).result) || {}
- rescue Psych::SyntaxError => e
- raise "YAML syntax error occurred while parsing #{config_file}. " \
- "Please note that YAML must be consistently indented using spaces. Tabs are not allowed. " \
- "Error: #{e.message}"
- end
+ config.to_prepare do
+ if config_choice = Rails.configuration.active_storage.service
+ configs = Rails.configuration.active_storage.service_configurations ||= begin
+ config_file = Pathname.new(Rails.root.join("config/storage.yml"))
+ raise("Couldn't find Active Storage configuration in #{config_file}") unless config_file.exist?
+
+ require "yaml"
+ require "erb"
+
+ YAML.load(ERB.new(config_file.read).result) || {}
+ rescue Psych::SyntaxError => e
+ raise "YAML syntax error occurred while parsing #{config_file}. " \
+ "Please note that YAML must be consistently indented using spaces. Tabs are not allowed. " \
+ "Error: #{e.message}"
+ end
ActiveStorage::Blob.service =
begin