Can I get the Ruby on Rails console to remember my command history, umm, better?

Ruby on-Rails-3Rails Console

Ruby on-Rails-3 Problem Overview


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.

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`

Ruby on-Rails-3 Solutions


Solution 1 - Ruby on-Rails-3

From How To – Persist Rails or IRB Console Command History After Exit.

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"

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionjcollumView Question on Stackoverflow
Solution 1 - Ruby on-Rails-3ctcherryView Answer on Stackoverflow