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?
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.
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 .
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.
We can exit the Rails console by typing exit.
Look at ~/.irb-history
, you will find the history there.
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With