[ACCEPTED]-Deleting a record from database-activerecord

Accepted answer
Score: 35

@variable.destroy will call all callbacks (before_destroy 5 etc.) as well as ensure associations are 4 respected. @variable.delete just calls the raw database 3 query to delete the object. You're generally 2 much safer off using destroy even if it's more 1 expensive.

Score: 2

Assuming that you're using ActiveRecord, and 2 that @variable is an instance of an ActiveRecord::Base subclass, you 1 call @variable.destroy.

More Related questions