5

Hi I am using Heroku and Ruby on Rails. In heroku I can do

heroku run rails c -a app

Which gives me console access, and I can do administrative things like deleting records

I am working in a company setting and I would like to have a log of all commands entered in the console. So if something is wrong, we can audit the logs.

Is there a way to record what is typed in the rails console?

Ken Liu
  • 22,503
  • 19
  • 75
  • 98
sonnyhe2002
  • 2,091
  • 3
  • 19
  • 31
  • 1
    Similar to http://stackoverflow.com/questions/11601303/how-to-view-the-entire-rails-console-history – AnkitG May 28 '15 at 03:30
  • This is mostly something that Heroku should offer, not something to solve in Rails: as other people answered: rails logs this already, just that Heroku does not expose those logs. You may want to reconsider the solution though: have you considered writing rake tasks to do the actions and locking down console? If you need to audit the console, you are probably abusing it in ways it was not meant to. – berkes Mar 28 '19 at 16:28

2 Answers2

2

Rails allows you to store the console history but this won't be saved in Heroku, at least not permanently.

In Heroku, when you run heroku run rails console Heroku will create a one-off dyno which will only live as long as the console session. Rails will store the history of commands on the filesystem but once the console is exited the dyno will be cleaned up and the command history file will be deleted along with it.

Rails console is a Railtie and it has some lifecycle hooks, so you could come up with some custom way to persist commands, but there is no built-in way to do it.

Ken Liu
  • 22,503
  • 19
  • 75
  • 98
0

Yes, you can now using Heroku's shield private spaces, https://elements.heroku.com/addons/heroku-private-spaces.