'How to view the entire Rails console history?

Does anyone know how to view the "history" in the rails console?

Pressing the up arrow lets me iterate through recent commands, but I'd like to see them all together in a list. I'm basically looking for the rails equivalent of the Unix history utility.

Is this possible in rails? If so, how?



Solution 1:[1]

Look at ~/.irb-history, you will find the history there.

Solution 2:[2]

The best equivalent to the history command would be

puts Readline::HISTORY.to_a

inside the IRB session. This has the advantage that no filesystem logging to any of the$HOME/.*_history files needs to be configured (as is the case in AWS elastic beanstalk instances).

Solution 3:[3]

I've tried the accepted answer, but our server didn't have a ~/.irb-history.

As it turned out, the history was kept in ~/.pry_history. Hope this helps.

Solution 4:[4]

Since we're already in the console,

lines = File.read("#{ENV['HOME']}/.pry_history");

or

lines = File.read("#{ENV['HOME']}/.irb-history");

then,

puts lines

Solution 5:[5]

Try CTRL+R to open the search in the history

Solution 6:[6]

We can view it by using following command in console

cat ~/.irb-history

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Chloe
Solution 2 Perseids
Solution 3 Ja͢ck
Solution 4 valk
Solution 5 Jan Sršeň
Solution 6 General Grievance