Skip to main content

Rails console

To access an interactive Rails console, run:
Then start using the console, but be careful! You’re in a production environment.
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 the root user, run:
To access an interactive shell as the rails user, requires a tiny bit of setup:
Accept the changes to your Dockerfile, and then rerun 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:
Accept the changes to your Dockerfile, and then rerun fly deploy. Once this is complete, you can execute other commands on Fly, for example:
To list all the available tasks, run:

Custom Rake tasks

You can create Custom Rake Tasks to automate frequently used commands. As an example, add the following into lib/tasks/fly.rake to reduce the number of keystrokes it takes to launch a console:
You can run these tasks with bin/rails fly:ssh, bin/rails fly:console, and bin/rails fly:dbconsole respectively.