Skip to content

Commit

Permalink
Replace update_all to update_column in CarrierWave storage
Browse files Browse the repository at this point in the history
  • Loading branch information
ollym authored Nov 5, 2023
1 parent 07811e7 commit b854b88
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions lib/cloudinary/carrier_wave/storage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,7 @@ def store_cloudinary_identifier(version, filename, resource_type=nil, type=nil)
end

if defined?(ActiveRecord::Base) && uploader.model.is_a?(ActiveRecord::Base)
primary_key = model_class.primary_key.to_sym
if defined?(::ActiveRecord::VERSION::MAJOR) && ::ActiveRecord::VERSION::MAJOR > 2
model_class.where(primary_key=>uploader.model.send(primary_key)).update_all(column=>name)
else
# Removed since active record version 3.0.0
model_class.update_all({column=>name}, {primary_key=>uploader.model.send(primary_key)})
end
uploader.model.send :write_attribute, column, name
uploader.model.update_column(column, name)
elsif defined?(Mongoid::Document) && uploader.model.is_a?(Mongoid::Document)
# Mongoid support
if Mongoid::VERSION.split(".").first.to_i >= 4
Expand Down

0 comments on commit b854b88

Please sign in to comment.