Merge pull request #37018 from santib/fix-activestorage-conditions

Fix conditions in ActiveStorage
This commit is contained in:
George Claghorn 2019-08-22 16:21:13 -04:00 committed by GitHub
commit e5c143c401
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -97,13 +97,13 @@ module ActiveStorage
def #{name}=(attachables)
if ActiveStorage.replace_on_assign_to_many
attachment_changes["#{name}"] =
if attachables.nil? || Array(attachables).none?
if Array(attachables).none?
ActiveStorage::Attached::Changes::DeleteMany.new("#{name}", self)
else
ActiveStorage::Attached::Changes::CreateMany.new("#{name}", self, attachables)
end
else
if !attachables.nil? || Array(attachables).any?
if Array(attachables).any?
attachment_changes["#{name}"] =
ActiveStorage::Attached::Changes::CreateMany.new("#{name}", self, #{name}.blobs + attachables)
end