Flowdock
method

delete

Importance_2
v2.2.1 - Show latest stable - 0 notes - Class: ActiveRecord::Base
delete(id) public

Delete an object (or multiple objects) where the id given matches the primary_key. A SQL DELETE command is executed on the database which means that no callbacks are fired off running this. This is an efficient method of deleting records that don’t need cleaning up after or other actions to be taken.

Objects are not instantiated with this method, and so :dependent rules defined on associations are not honered.

Parameters

Examples

  # Delete a single object
  Todo.delete(1)

  # Delete multiple objects
  todos = [1,2,3]
  Todo.delete(todos)
Show source
Register or log in to add new notes.