Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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)


`destroy` instantiates active record models which kind of defeats the purpose of fast deletion :)


You 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


I'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 :(


this 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.


Though you're still left to deal with your destroy callbacks/observers, if you have any.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: