Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Postgres doesn't like checking for the value 'true' in date/time fields

  • Loading branch information...
commit ff8ae28c875d9ddd4a70718f1cf379add566acea 1 parent 9c23c60
Brian Underwood authored
Showing with 15 additions and 3 deletions.
  1. +15 −3 lib/rails3_acts_as_paranoid.rb
View
18 lib/rails3_acts_as_paranoid.rb
@@ -14,6 +14,20 @@ def acts_as_paranoid(options = {})
raise ArgumentError, "'time' or 'boolean' expected for :column_type option, got #{configuration[:column_type]}"
end
+ only_deleted_method_code =
+ if configuration[:column_type] == 'time'
+ <<-EOV
+ self.unscoped.
+ where("#{self.table_name}.#{configuration[:column]} IS NOT ?", nil)
+EOV
+ else
+ <<-EOV
+ self.unscoped.
+ where("#{self.table_name}.#{configuration[:column]} IS NOT ?
+ OR #{self.table_name}.#{configuration[:column]} != ?", nil, true)
+EOV
+ end
+
class_eval <<-EOV
default_scope where("#{self.table_name}.#{configuration[:column]} IS ?", nil)
@@ -23,9 +37,7 @@ def with_deleted
end
def only_deleted
- self.unscoped.
- where("#{self.table_name}.#{configuration[:column]} IS NOT ?
- OR #{self.table_name}.#{configuration[:column]} != ?", nil, true)
+ #{only_deleted_method_code}
end
def delete_all!(conditions = nil)
Please sign in to comment.
Something went wrong with that request. Please try again.