Module: DaisybillApi::Ext::CRUD::Destroy::InstanceMethods

Defined in:
lib/daisybill_api/ext/crud/destroy.rb

Instance Method Summary collapse

Instance Method Details

#destroyObject

Deleting records

bill = DaisybillApi::Models::Bill.find(12) # => <DaisybillApi::Models::Bill id: 12>
bill.destroy # => true
DaisybillApi::Models::Bill.find(12) # => nil

Some records will not be deletable depending on their conditions:

bill = DaisybillApi::Models::Bill.find(1) # => <DaisybillApi::Models::Bill id: 1...>
bill.status  # => "done"
bill.destroy # => false
bill.errors.full_messages # => ["Bill is not deletable"]


21
22
23
# File 'lib/daisybill_api/ext/crud/destroy.rb', line 21

def destroy
  @destroyed = send_data :delete, show_path
end