module RailsSoftDeletable::Query::ClassMethods
Public Instance Methods
only_deleted()
click to toggle source
# File lib/rails_soft_deletable/query.rb, line 22 def only_deleted with_deleted.where("#{self.table_name}.#{soft_deletable_column} > 0") end
Also aliased as: deleted
restore(id)
click to toggle source
# File lib/rails_soft_deletable/query.rb, line 27 def restore(id) if id.is_a?(Array) id.map { |one_id| restore(one_id) } else only_deleted.find(id).restore! end end
soft_deletable?()
click to toggle source
# File lib/rails_soft_deletable/query.rb, line 8 def soft_deletable? true end
with_deleted()
click to toggle source
# File lib/rails_soft_deletable/query.rb, line 12 def with_deleted if ::ActiveRecord::VERSION::STRING >= "4.1" self.unscope(where: soft_deletable_column).all elsif ::ActiveRecord::VERSION::STRING >= "4.0" all.tap { |x| x.default_scoped = false } else scoped.tap { |x| x.default_scoped = false } end end