Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 389
dB' Avatar asked Jul 22 '12 14:07

dB'


People also ask

Where is Rails console history stored?

IRB or rails console commands are stored in the file irb-history. If you are using pry. You can find your history in ~/. pry_history file.

How do I open the Rails console in Terminal?

2.3 bin/rails console You can also use the alias "c" to invoke the console: bin/rails c . You can specify the environment in which the console command should operate. If you wish to test out some code without changing any data, you can do that by invoking bin/rails console --sandbox .

What is GitLab Rails console?

The Rails console. provides a way to interact with your GitLab instance from the command line. The Rails console interacts directly with GitLab. In many cases, there are no handrails to prevent you from permanently modifying, corrupting or destroying production data.

How to exit Rails console?

We can exit the Rails console by typing exit.


2 Answers

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

like image 69
lucas clemente Avatar answered Oct 02 '22 03:10

lucas clemente


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).

like image 23
Perseids Avatar answered Oct 02 '22 02:10

Perseids