lib/is_paranoid.rb in semanticart-is_paranoid-0.9.3 vs lib/is_paranoid.rb in semanticart-is_paranoid-0.9.4
- old
+ new
@@ -58,12 +58,12 @@
# Android.restore(:include => [:home, :planet], :include_destroyed_dependents => true)
def restore(id, options = {})
options.reverse_merge!({:include_destroyed_dependents => true}) unless options[:include]
with_exclusive_scope do
update_all(
- "#{destroyed_field} = #{connection.quote(field_not_destroyed)}",
- "id = #{id}"
+ "#{destroyed_field} = #{connection.quote(field_not_destroyed)}",
+ primary_key.to_sym => id
)
end
self.reflect_on_all_associations.each do |association|
if association.options[:dependent] == :destroy and association.klass.respond_to?(:restore)
@@ -210,10 +210,10 @@
# Mark the model deleted_at as now.
def destroy_without_callbacks
self.class.update_all(
"#{destroyed_field} = #{self.class.connection.quote(( field_destroyed.respond_to?(:call) ? field_destroyed.call : field_destroyed))}",
- "id = #{self.id}"
+ self.class.primary_key.to_sym => self.id
)
self
end
# Override the default destroy to allow us to flag deleted_at.