Rails4

@dwradcliffe I've merged master back into the rails4 branch so we can work with the most recent changes since the last commit to this branch.

I will base the rest of the upgrade from this point forwards