Module: ZombieRecord::Restorable::ClassMethods

Defined in:
lib/zombie_record/restorable.rb

Instance Method Summary collapse

Instance Method Details

#deletedObject

Scopes the relation to only include deleted records.

Returns an ActiveRecord::Relation.



161
162
163
# File 'lib/zombie_record/restorable.rb', line 161

def deleted
  with_deleted.where("#{quoted_table_name}.deleted_at IS NOT NULL")
end

#with_deletedObject

Scopes the relation to include both active and deleted records.

Returns an ActiveRecord::Relation.



168
169
170
171
172
# File 'lib/zombie_record/restorable.rb', line 168

def with_deleted
  all.
    unscope(where: :deleted_at).
    extending(WithDeletedAssociationsWrapper)
end