Please read for an updated status on RailsCasts:
Learn more or hide this
GitHub User: wintermeyer
I agree with your point of solving this in a model instead of a sweeper in the controller. It took me a couple of hours to solve this problem the IMO proper way.
Add the following to your model in a Rails 3.2 app (here the Class is Company):