Method: Paranoia#paranoia_delete

Defined in:
lib/paranoia.rb

#paranoia_deleteObject Also known as: delete

Raises:

  • (ActiveRecord::ReadOnlyRecord)


94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/paranoia.rb', line 94

def paranoia_delete
  raise ActiveRecord::ReadOnlyRecord, "#{self.class} is marked as readonly" if readonly?
  if persisted?
    # if a transaction exists, add the record so that after_commit
    # callbacks can be run
    add_to_transaction
    update_columns(paranoia_destroy_attributes)
  elsif !frozen?
    assign_attributes(paranoia_destroy_attributes)
  end
  self
end