本文介绍了我可以让 Ruby on Rails 控制台记住我的命令历史,嗯,更好吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我在 Ruby on Rails 3.1.1 中使用控制台,我发现它的命令历史记录(向上箭头)非常不稳定.我今天在多个控制台会话中多次运行命令 p = Product.by_name 'Acme'p.add_search_term('Snipe').

I'm using the console in Ruby on Rails 3.1.1, and I'm finding its command history (up arrow) to be really flaky. I've run the commands p = Product.by_name 'Acme' and p.add_search_term('Snipe') several times today, across several console sessions.

然而,当我重新加载 Ruby on Rails 控制台时,我的命令历史中只显示第一个,而不是第二个.有时,在我重新加载控制台后,它们都在历史记录中.最重要的是,我在我的历史记录中看到了几天前按下向上箭头几次后的命令.我需要更改某种配置还是这是一个错误?

Yet, when I reload the Ruby on Rails console, only the first one shows in my command history, not the second. Sometimes they are both there in the history after I reload the console. On top of that, I see commands in my history that are from several days ago after pressing up arrow only a few times. Is there some sort of configuration that I need to change or is this a bug?

  • Ruby on Rails 3.1.1`
  • Ruby 1.9.2p290`
  • Ubuntu 11.10`

推荐答案

来自 如何 - 退出后保留 Rails 或 IRB 控制台命令历史.

创建或编辑您的 ~/.irbrc 文件以包含:

Create, or edit your ~/.irbrc file to include:

require 'irb/ext/save-history'
IRB.conf[:SAVE_HISTORY] = 200
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-history"

这篇关于我可以让 Ruby on Rails 控制台记住我的命令历史,嗯,更好吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-07 02:12