Update to Rails4 and gem compatibilities

Thanks also to @selivandex!