aboutsummaryrefslogtreecommitdiffstats
path: root/activestorage/lib
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2017-08-05 09:11:02 -0500
committerGitHub <noreply@github.com>2017-08-05 09:11:02 -0500
commit616f3611d525b97c5cdb1a5feee25621cca27daf (patch)
tree79591ed29b2a9670519438bce2d53f1a096cee06 /activestorage/lib
parentbb7599a6c84aba44cbb5f21486ffdb4a549717dd (diff)
parent6df24c693ed50a66feaf116c90df7eba5acf4033 (diff)
downloadrails-616f3611d525b97c5cdb1a5feee25621cca27daf.tar.gz
rails-616f3611d525b97c5cdb1a5feee25621cca27daf.tar.bz2
rails-616f3611d525b97c5cdb1a5feee25621cca27daf.zip
Merge branch 'master' into ast-module
Diffstat (limited to 'activestorage/lib')
-rw-r--r--activestorage/lib/active_storage/attached/macros.rb12
-rw-r--r--activestorage/lib/active_storage/engine.rb2
-rw-r--r--activestorage/lib/active_storage/gem_version.rb4
-rw-r--r--activestorage/lib/active_storage/service/azure_storage_service.rb2
4 files changed, 13 insertions, 7 deletions
diff --git a/activestorage/lib/active_storage/attached/macros.rb b/activestorage/lib/active_storage/attached/macros.rb
index fbd64b5edc..5779348148 100644
--- a/activestorage/lib/active_storage/attached/macros.rb
+++ b/activestorage/lib/active_storage/attached/macros.rb
@@ -23,8 +23,11 @@ module ActiveStorage
# (i.e. destroyed) whenever the record is destroyed.
def has_one_attached(name, dependent: :purge_later)
define_method(name) do
- instance_variable_get("@active_storage_attached_#{name}") ||
+ if instance_variable_defined?("@active_storage_attached_#{name}")
+ instance_variable_get("@active_storage_attached_#{name}")
+ else
instance_variable_set("@active_storage_attached_#{name}", ActiveStorage::Attached::One.new(name, self))
+ end
end
has_one :"#{name}_attachment", -> { where(name: name) }, class_name: "ActiveStorage::Attachment", as: :record
@@ -61,8 +64,11 @@ module ActiveStorage
# (i.e. destroyed) whenever the record is destroyed.
def has_many_attached(name, dependent: :purge_later)
define_method(name) do
- instance_variable_get("@active_storage_attached_#{name}") ||
+ if instance_variable_defined?("@active_storage_attached_#{name}")
+ instance_variable_get("@active_storage_attached_#{name}")
+ else
instance_variable_set("@active_storage_attached_#{name}", ActiveStorage::Attached::Many.new(name, self))
+ end
end
has_many :"#{name}_attachments", -> { where(name: name) }, as: :record, class_name: "ActiveStorage::Attachment"
@@ -75,4 +81,4 @@ module ActiveStorage
end
end
end
-end
+end \ No newline at end of file
diff --git a/activestorage/lib/active_storage/engine.rb b/activestorage/lib/active_storage/engine.rb
index 1d345920fa..da83d3908a 100644
--- a/activestorage/lib/active_storage/engine.rb
+++ b/activestorage/lib/active_storage/engine.rb
@@ -27,7 +27,7 @@ module ActiveStorage
initializer "active_storage.verifier" do
config.after_initialize do |app|
- if app.config.secret_key_base.present?
+ if app.secrets.secret_key_base.present?
ActiveStorage.verifier = app.message_verifier("ActiveStorage")
end
end
diff --git a/activestorage/lib/active_storage/gem_version.rb b/activestorage/lib/active_storage/gem_version.rb
index cde112a006..db79c669bf 100644
--- a/activestorage/lib/active_storage/gem_version.rb
+++ b/activestorage/lib/active_storage/gem_version.rb
@@ -5,8 +5,8 @@ module ActiveStorage
end
module VERSION
- MAJOR = 0
- MINOR = 1
+ MAJOR = 5
+ MINOR = 2
TINY = 0
PRE = "alpha"
diff --git a/activestorage/lib/active_storage/service/azure_storage_service.rb b/activestorage/lib/active_storage/service/azure_storage_service.rb
index 62b13433fe..c2e1b25a43 100644
--- a/activestorage/lib/active_storage/service/azure_storage_service.rb
+++ b/activestorage/lib/active_storage/service/azure_storage_service.rb
@@ -20,7 +20,7 @@ module ActiveStorage
instrument :upload, key, checksum: checksum do
begin
blobs.create_block_blob(container, key, io, content_md5: checksum)
- rescue Azure::Core::Http::HTTPError => e
+ rescue Azure::Core::Http::HTTPError
raise ActiveStorage::IntegrityError
end
end