Rails 4 compatibility

Some fixes to use the gem with Rails 4.0.0.beta1