[ACCEPTED]-Deleting a record from database-activerecord
Accepted answer
@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.
Assuming that you're using ActiveRecord, and 2 that @variable
is an instance of an ActiveRecord::Base
subclass, you 1 call @variable.destroy
.
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.