Skip to content
Switch branches/tags
Go to file

Latest commit

It may be enabled the cop in future, but it will be disabled for the time
being as code and comment repeats are not DRY.

Git stats


Failed to load latest commit information.

RuboCop Rails

Gem Version CircleCI

A RuboCop extension focused on enforcing Rails best practices and coding conventions.

Note: This repository manages rubocop-rails gem (>= 2.0.0). rubocop-rails gem (<= 1.5.0) has been renamed to rubocop-rails_config gem.


Just install the rubocop-rails gem

gem install rubocop-rails

or if you use bundler put this in your Gemfile

gem 'rubocop-rails', require: false


You need to tell RuboCop to load the Rails extension. There are three ways to do this:

RuboCop configuration file

Put this into your .rubocop.yml.

require: rubocop-rails

Alternatively, use the following array notation when specifying multiple extensions.

  - rubocop-other-extension
  - rubocop-rails

Now you can run rubocop and it will automatically load the RuboCop Rails cops together with the standard cops.

Command line

rubocop --require rubocop-rails

Note: --rails option is required while rubocop command supports --rails option.

Rake task do |task|
  task.requires << 'rubocop-rails'

The Cops

All cops are located under lib/rubocop/cop/rails, and contain examples/documentation.

In your .rubocop.yml, you may treat the Rails cops just like any other cop. For example:

    - lib/example.rb


You can read a lot more about RuboCop Rails in its official docs.


Rails cops support the following versions:

  • Rails 4.2+

Readme Badge

If you use RuboCop Rails in your project, you can include one of these badges in your readme to let people know that your code is written following the community Rails Style Guide.

Rails Style Guide

Rails Style Guide

Here are the Markdown snippets for the two badges:

[![Rails Style Guide](](

[![Rails Style Guide](](


Checkout the contribution guidelines.


rubocop-rails is MIT licensed. See the accompanying file for the full text.