Special Notes Lookup in Rails
Posted on November 6, 2012 • 1 minutes • 125 words
Add special notes to your source code comments in Rails to later remind you of tasks you need to complete:
class Article < ActiveRecord::Base
# TODO add named_scopes
# FIXME method A is broken
# OPTIMIZE improve the code
has_many :comments
....
end
Some programming IDEs, such as Aptana Studio 3 (free), will even highlight the key notation part.
Now, from the command line, you can list these special notes with a rake task:
$ rake notes
app/models/article.rb:
* [2] [TODO] add named_scopes
* [3] [FIXME] method A is broken
* [4] [OPTIMIZE] improve the code
You can also list notes of each kind individually with rake notes:todo
, rake notes:fixme
and rake notes:optimize
.
You can even list your own, custom notes with rake notes:custom ANNOTATION=MYANNO
.