Updated to work with the current rails41 branch