Rails 4 compatibility

@hired/developers care to take a look?

We are using this branch in production - it's just time to get it merged and released (no support for Rails 4 released as in the gem yet).