Strange Rails Behaviour with MySQL (delete cascade)

You can also have AR handle the referential integrity:

class Group < ActiveRecord::Base
   has_many :ranks, :dependent => :destroy

class Rank
  belongs_to :group

When you delete a group, AR will delete its ranks in the same
transaction so you shouldn't see the delay.

Or course you might want to also declare the constraints in SQL if non
AR code is manipulating the database.