Home Rails Notes Explained
Post
Cancel

Rails Notes Explained

In this post you will learn how to list down all of your todos, fixme, optimize tags from the rails project.

In your rails project if you run rake notes (you can also use rails notes in rails 5+ projects) in your terminal, it will search for comments beginning with a specific keyword and it will print you the filename and line number for your:

For example, we have given controller with comments

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
class PostsController < ApplicationController
  before_action :set_post, only: %i[ show edit update destroy ]

  # TODO: Write a testcase for index action
  def index
    @posts = Post.all
  end

  # OPTIMIZE: Show action is taking too much memory, optimize it
  def show
  end

  # FIXME: new action has bad code, refactor it!
  def new
    @post = Post.new
  end
end

and if we run rails notes

1
2
3
4
5
> rails notes
app/controllers/posts_controller.rb:
  * [ 5] [TODO] Write a testcase for index action
  * [11] [OPTIMIZE] show action is taking too much memory, optimize it
  * [15] [FIXME] new action have bad code, refactor it!

More Info

This post is licensed under CC BY 4.0 by the author.