Class: DeletedItem

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/deleted_item.rb

Class Method Summary collapse

Class Method Details

.save_and_destroy(item, deleted_by) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
# File 'app/models/deleted_item.rb', line 3

def self.save_and_destroy(item, deleted_by)
  DeletedItem.create(
    item_type: item.class.to_s,
    item_id: item.id,
    yaml: item.to_yaml,
    json: item.to_json,
    deleted_by_id: deleted_by.id
  )

  item.destroy
end