Module: ActiveRecord::Persistence

Defined in:
lib/zombie_record.rb

Instance Method Summary collapse

Instance Method Details

#destroy_rowObject

Maybe override Rails’ #destroy_row for soft-delete functionality



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/zombie_record.rb', line 14

def destroy_row
  if self.class.include?(ZombieRecord::Restorable)
    time = current_time_from_proper_timezone

    update_params = { deleted_at: time }
    if self.class.column_names.include?("updated_at")
      update_params[:updated_at] = time
    end

    update_columns(update_params) ? 1 : 0
  else
    zombie_record_alias_destroy_row
  end
end

#zombie_record_alias_destroy_rowObject



11
# File 'lib/zombie_record.rb', line 11

alias_method :zombie_record_alias_destroy_row, :destroy_row