1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Set ActiveStorage::Blob.service when ActiveStorage::Blob is loaded

Fixes that ActiveStorage::Blob.service is unset when ActiveStorage::Blob
is reloaded.
This commit is contained in:
George Claghorn 2017-08-07 13:11:10 -04:00
parent 4b72bee47b
commit caf7e62301

View file

@ -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?
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"
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
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