4 ms·
You might want to use 'destroy' instead of 'delete', as 'delete' skips all ActiveRecord callbacks (i. e., if you had a dependent: :destroy callback for post com
by janus 14y ago
You might want to use 'destroy' instead of 'delete', as 'delete' skips all ActiveRecord callbacks (i. e., if you had a dependent: :destroy callback for post comments, using 'delete' would leave them intact)
- xentronium 14y ago`destroy` instantiates active record models which kind of defeats the purpose of fast deletion :)
- janus 14y agoYou are right, well in that case, you would have to delete associated records manually if you didn't add any foreign keys at the db level
- chris_wot 14y agoI'd suggest deleting or dealing with those records anyway, regardless of whether you added FKs! But... if you don't add FKs, you've got bigger issues to deal with :(
- joevandyk 14y agothis is why i prefer using "on delete cascade" in schemas, no need to transmit lots of data over the wire and instantiate thousands of slow activerecord objects when deleting stuff.
- randomdata 14y agoThough you're still left to deal with your destroy callbacks/observers, if you have any.