Rails4 support which plays nice even with Rails 3

/cc @jtomaszewski, @artembiserov, @dmitrytrager