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.


167
168
169
# File 'lib/zombie_record/restorable.rb', line 167

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.


174
175
176
177
178
# File 'lib/zombie_record/restorable.rb', line 174

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