Skip to Content

Rails - `rails notes` command

Posted on

There are many Rails command line which we use everyday: rails console, rails server, rails generate, rails db:migrate, rails db:create, rails routes, rails new, …. In addtion, it also suports other useful command line. You can get list of Rails commands available to you by typing: rails --help.

Today, I learn a new command line - rails notes

rails notes

rails notes search through your code for comments starting with specific keywords. By default, it searches for:

  • Keywords: TODO, FIXME and OPTIMIZE.
  • In folder: app, config, db, lib, test.
  • With file extensions: .rb, .rake, .css, .js, .erb, .ruby, .yml, .yaml`

Usage

  • rails notes:fixme, rails notes:optimize, rails note:todo - Get only list of FIXME, OPTIMIZE or TODO
  • rails notes --annotations FIXME RELEASE - Get list with custom tags

Custom config

# Register more tags
config.annotations.register_tags("DEPRECATEME", "TESTME")

# Register more directories for searching
config.annotations.register_directories("spec", "vendor")

# Register more extensions file for searching
config.annotations.register_extensions("scss", "sass") { |annotation| /\/\/\s*(#{annotation}):?\s*(.*)$/ }

References:

comments powered by Disqus