【发布时间】:2014-01-08 16:09:52
【问题描述】:
在 Rails 4 rails console 中,我可以键入 history,它的行为就像 bash shell 中的 history 命令一样。例如:
[25] my_rails_project » history
1: Nomination
2: {:ad => "asdfsdasadf"}
3: Nomination.count
4: Nomination.count.to_sql
5: Nomination.all.class
6: Nomination.all.to_sql
...
有没有办法搜索该历史记录,例如history | grep Nomination?尾巴呢?
注意:当我最初写这个问题时,我认为history 命令来自Rails 本身,但它来自我系统中的pry gem(我的Gemfile 指定了jazz_hands gem撬)。 Pry 实际上有一个grep 功能,例如history --grep Nomination 会给我上面的第 1 行和第 3-6 行。它还具有tail 功能。这些记录在这里:https://github.com/pry/pry/wiki/History
【问题讨论】:
-
实际上,pry 的历史命令是
hist-- 我不确定history究竟是一个合法的命令。 -
history和hist是 pry 中的别名 :)
标签: ruby-on-rails history irb pry