News for hackers. Stuff that matters.
Re:Five Common Rails Mistakes by janus on Sunday May 06, 2012 @09:49AM (#3935115)
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)
Re:Five Common Rails Mistakes by xentronium on Sunday May 06, 2012 @10:22AM (#3935178)
`destroy` instantiates active record models which kind of defeats the purpose of fast deletion :)
Re:Five Common Rails Mistakes by janus on Sunday May 06, 2012 @12:11PM (#3935457)
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
Re:Five Common Rails Mistakes by chris_wot on Monday May 07, 2012 @05:24AM (#3938292)
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 :(
Re:Five Common Rails Mistakes by joevandyk on Sunday May 06, 2012 @02:35PM (#3935870)
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.
Re:Five Common Rails Mistakes by randomdata on Sunday May 06, 2012 @02:48PM (#3935911)
Though you're still left to deal with your destroy callbacks/observers, if you have any.