Move showing alerts into a shared function.
Update gems and Rails to the 4.0.0 release.