Upgrade to Rails 4

Thanks to everyone who helped with this. Finally the tests pass so this is PR-able. Sorry, this is giant. :sunny:
There have been several security releases since 4.0.4. Can you bump to the latest (4.0.8)?