Method: Parse::Core::Actions#destroy

Defined in:
lib/parse/model/core/actions.rb

#destroy(session: nil) ⇒ Boolean

Delete this record from the Parse collection. Only valid if this object has an id. This will run all the destroy callbacks.

Parameters:

  • session (String) (defaults to: nil)

    a session token if you want to apply ACLs for a user in this operation.

Returns:

  • (Boolean)

    whether the operation was successful.

Raises:

  • ArgumentError if a non-nil value is passed to session that doesn’t provide a session token string.



552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
# File 'lib/parse/model/core/actions.rb', line 552

def destroy(session: nil)
  @_session_token = _validate_session_token! session, :destroy
  return false if new?
  success = false
  run_callbacks :destroy do
    res = client.delete_object parse_class, id, session_token: _session_token
    success = res.success?
    if success
      @id = nil
      changes_applied!
    elsif self.class.raise_on_save_failure
      raise Parse::RecordNotSaved.new(self), "Failed to create or save attributes. #{self.parse_class} was not saved."
    end
    # Your create action methods here
  end
  @_session_token = nil
  success
end