aboutsummaryrefslogtreecommitdiffstats
path: root/activestorage/lib
diff options
context:
space:
mode:
authorRafael França <rafaelmfranca@gmail.com>2017-08-08 17:10:58 -0400
committerGitHub <noreply@github.com>2017-08-08 17:10:58 -0400
commit673fb4c433b58bd67bbf473598b5e35631e07b30 (patch)
tree750c6cf00640899e616d376e899b6c322ab0c352 /activestorage/lib
parent3c560b2a55bd287b94d27e01ea231ef9d60e5489 (diff)
parentcaf7e623017311c3b857ab84402e1baa9bfba4f4 (diff)
downloadrails-673fb4c433b58bd67bbf473598b5e35631e07b30.tar.gz
rails-673fb4c433b58bd67bbf473598b5e35631e07b30.tar.bz2
rails-673fb4c433b58bd67bbf473598b5e35631e07b30.zip
Merge pull request #30118 from georgeclaghorn/active-storage-load-hooks
Set ActiveStorage::Blob.service when ActiveStorage::Blob is loaded
Diffstat (limited to 'activestorage/lib')
-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