Commit 56e1df53 by delba

use update_column

parent c1d4f029
......@@ -21,24 +21,17 @@ module Paranoia
def delete
return if new_record? or destroyed?
update_attribute_or_column :deleted_at, Time.now
update_column :deleted_at, Time.now
end
def restore!
update_attribute_or_column :deleted_at, nil
update_column :deleted_at, nil
end
def destroyed?
!self.deleted_at.nil?
end
alias :deleted? :destroyed?
private
# Rails 3.1 adds update_column. Rails > 3.2.6 deprecates update_attribute, gone in Rails 4.
def update_attribute_or_column(*args)
respond_to?(:update_column) ? update_column(*args) : update_attribute(*args)
end
end
class ActiveRecord::Base
......
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