Rails console
To access an interactive Rails console, run:The
--pty flag tells the SSH server to run the command in a pseudo-terminal. You will generally need this only when running interactive commands, like the Rails console.If you get a
no such file or directory error, your app may not be installed in the /rails directory. SSH in with fly ssh console and check your app’s location, then adjust the path accordingly. Apps built with the dockerfile generator use /rails as the working directory by default. You may also need to set up your binstubs with bin/rails generate dockerfile --bin-cd.Interactive shell
To access an interactive shell as theroot user, run:
rails user, requires a tiny bit of setup:
fly deploy.
Once this is complete, you can create an interactive shell:
Rails tasks
In order to run other Rails tasks, a small change is needed to your Rails binstubs to set the current working directory. The following command will make the adjustment for you:fly deploy.
Once this is complete, you can execute other commands on Fly, for example:
Custom Rake tasks
You can create Custom Rake Tasks to automate frequently used commands. As an example, add the following intolib/tasks/fly.rake to reduce the number of
keystrokes it takes to launch a console:
bin/rails fly:ssh, bin/rails fly:console,
and bin/rails fly:dbconsole respectively.