Commit 0e8b874c by Prem Sichanugrist

Use #unscoped or #with_exclusive_scope when selecting records for the rake task

parent 16d06c4a
...@@ -140,10 +140,13 @@ module Paperclip ...@@ -140,10 +140,13 @@ module Paperclip
# Find all instances of the given Active Record model +klass+ with attachment +name+. # Find all instances of the given Active Record model +klass+ with attachment +name+.
# This method is used by the refresh rake tasks. # This method is used by the refresh rake tasks.
def each_instance_with_attachment(klass, name) def each_instance_with_attachment(klass, name)
unscope_method = class_for(klass).respond_to?(:unscoped) ? :unscoped : :with_exclusive_scope
class_for(klass).send(unscope_method) do
class_for(klass).find(:all, :order => 'id').each do |instance| class_for(klass).find(:all, :order => 'id').each do |instance|
yield(instance) if instance.send(:"#{name}?") yield(instance) if instance.send(:"#{name}?")
end end
end end
end
# Log a paperclip-specific line. This will logs to STDOUT # Log a paperclip-specific line. This will logs to STDOUT
# by default. Set Paperclip.options[:log] to false to turn off. # by default. Set Paperclip.options[:log] to false to turn off.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment