# Ruby on Rails

How to deploy Ruby on Rails apps with Hatchbox

## Build Steps

When Hatchbox detects `rails` in the `Gemfile` in the repository, it will trigger the Rails build process.

1. Install the Ruby version from `.ruby-version`, `.tool-versions`, or `Gemfile.lock`
2. Install the correct Bundler version and dependencies
3. Check for assets:precompile and run it (API-only apps won&#39;t have this)
4. Check for db:migrate and run it on the `cron` server (so it only runs once a deploy)

After building, Hatchbox will add a process for the Rails server on the first deploy. Hatchbox will also add processes for Sidekiq and Solid Queue if detected as well on the first deploy.

## Multiple Database Support

Rails ships with the Solid gems by default: solid\_queue, solid\_cache, and solid\_cable. For production, your Rails application needs a database configured for each.

Assign a database for each using the matching environment variable name:

- `DATABASE_URL`
- `QUEUE_DATABASE_URL`
- `CACHE_DATABASE_URL`
- `CABLE_DATABASE_URL`

## Processes

On your first deploy, Hatchbox will detect Rails and add a process with the following command.

```
bin/rails server -b 127.0.0.1 -p $PORT
```

If Solid Queue is detected, another process will be added.

```
bin/jobs
```

If Sidekiq is detected, another process will be added.

```
bundle exec sidekiq
```
