Skip to content

Commit

Permalink
Fixed alias bug by reordering is_paranoid actions
Browse files Browse the repository at this point in the history
  • Loading branch information
ndbroadbent committed Nov 23, 2011
1 parent e18e9d9 commit 84858f2
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions vendor/plugins/is_paranoid/lib/is_paranoid.rb
Expand Up @@ -16,21 +16,21 @@ module ClassMethods
# end
def is_paranoid
unless included_modules.include?(InstanceMethods)
extend SingletonMethods
include InstanceMethods
# Override the default destroy to allow us to flag deleted_at.
# This preserves the before_destroy and after_destroy callbacks.
# Because this is also called internally by Model.destroy_all and
# the Model.destroy(id), we don't need to specify those methods
# separately.
alias_method :destroy!, :destroy

# This is the real magic. All calls made to this model will
# append the conditions deleted_at => nil. Exceptions require
# using with_destroyed_scope (see self.delete_all,
# self.count_with_destroyed, and self.find_with_destroyed )
default_scope where(:deleted_at => nil)

# Override the default destroy to allow us to flag deleted_at.
# This preserves the before_destroy and after_destroy callbacks.
# Because this is also called internally by Model.destroy_all and
# the Model.destroy(id), we don't need to specify those methods
# separately.
alias_method :destroy!, :destroy
include InstanceMethods
extend SingletonMethods
end
end
end
Expand Down

0 comments on commit 84858f2

Please sign in to comment.