Replace a Rails-specific method with a more general ruby implementation