Rails 4 support

Some quick changes I just made to get it working with Rails 4. Not sure if I've done it right, but here goes! :smile: 

**NB: This pull request has no backward support for pre-Rails 4.**