Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Commit

Permalink
Use #unscoped or #with_exclusive_scope when selecting records for the…
Browse files Browse the repository at this point in the history
… rake task
  • Loading branch information
sikachu committed Nov 18, 2011
1 parent 16d06c4 commit 0e8b874
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/paperclip.rb
Expand Up @@ -140,8 +140,11 @@ def register_processor(name, processor)
# Find all instances of the given Active Record model +klass+ with attachment +name+.
# This method is used by the refresh rake tasks.
def each_instance_with_attachment(klass, name)
class_for(klass).find(:all, :order => 'id').each do |instance|
yield(instance) if instance.send(:"#{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|
yield(instance) if instance.send(:"#{name}?")
end
end
end

Expand Down

0 comments on commit 0e8b874

Please sign in to comment.