# Rails 中的 TODO

问题描述 投票:0回答:5

我读过一本 Rails 书,发现我们可以在代码中添加 # TODO: 和一些 # 的东西,这样我们就可以用一些 rake cmd 来回顾一下。

我的问题是我找不到那些“# stuff”和“rake cmd”在哪里,我用谷歌搜索并搜索,但找不到也不知道要搜索哪些关键字。

ruby-on-rails ruby rake todo
5个回答
99
投票

您可以使用

# TODO
# FIXME
# OPTIMIZE
,并且您可以通过以下耙子任务轻松获得所有这些:
rake notes

除了默认注释之外,您始终可以指定和搜索自己的注释:

rake notes:custom ANNOTATION=ZOMG

18
投票

耙子笔记:todo


9
投票

顺便说一句,您需要从 Rails 应用程序的根目录运行该命令。另外,你可以运行:

rake -T

获取 Rails Rakefile 中任务的完整列表


6
投票
grep -rn "# TODO" .

0
投票

打印所有注释

$ bin/rails notes
app/models/user.rb:
  * [  110] [TODO] Refactor this 

test/test_helper.rb:
  * [   72] [FIXME] Unable to stub this method in the `sign_in` helper

打印具体注释(

FIXME
)

$ bin/rails notes -a FIXME
test/test_helper.rb:
  * [ 72] Unable to stub this method in the `sign_in` helper
© www.soinside.com 2019 - 2024. All rights reserved.