Rails 4 compatibility (2nd approach)

Some fixes to use the gem with Rails 4.0.0.beta1