No history for rails console

343 Views Asked by At

irb works fine, rails console doesnt!

~/.irbrc

require 'irb/ext/save-history'
IRB.conf[:SAVE_HISTORY] = 100
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-save-history"
> irb
irb(main):002:0> a="test"
=> "test"
irb(main):003:0> exit
> cat ~/.irb-save-history
a="test"
exit
> rails c
Running via Spring preloader in process 6238
Loading development environment (Rails 6.1.5.1)
[1] pry(main)> b="test"
=> "test"
[2] pry(main)> exit
> cat ~/.irb-save-history
a="test"
exit
1

There are 1 best solutions below

2
Vi. On

If you're using pry, your history will be in ~/.pry_history. If that's not the case, you will find all your history in ~/.irb_history

EDIT: depending on the OS, you could have ~/.irb-history (dash, not underscore) file too. So the most updated file should be one of these.