Run Rails and Rack apps locally

On this page

Short Leash serves Ruby apps at https://<name>.test: Rails apps, and Rack apps with a config.ru. Each runs on the Ruby version the project asks for, and Bundler installs missing gems before the server starts.

How does Short Leash recognize a Ruby app?

A folder with a Gemfile and config/application.rb is a Rails app. Short Leash runs bin/rails server, or bundle exec rails server without the binstub. A folder with a Gemfile and config.ru is a Rack app, run with Puma when it's in the bundle, otherwise rackup. Either way the server listens on 127.0.0.1 at the port Short Leash picks, and bundle install runs first when gems are missing.

Which Ruby version does a site use?

Short Leash offers Ruby 3.2, 3.3, 3.4 and 4.0. It picks, in order:

  1. The version chosen for the site on its Site settings.
  2. The version the project asks for: .ruby-version, then the RUBY VERSION in Gemfile.lock, the ruby line in the Gemfile, then .tool-versions.
  3. The default on the Runtimes screen, or the newest.

Ruby is downloaded the first time a site needs it. The download comes from Short Leash's own builds, checked against a signed list of SHA-256 sums. On a Mac they're built to work from any folder, with OpenSSL and libyaml included. On Windows, they're RubyInstaller's builds. Until Short Leash's build of a version is published, the site uses the ruby on your PATH.

How do I run Sidekiq, GoodJob or Solid Queue?

Open the site's Processes page and choose Add process. Short Leash suggests Sidekiq, GoodJob or Solid Queue (bin/jobs) when they're in Gemfile.lock, plus every process in Procfile.dev except web. Processes restart when they exit and start again with Short Leash.

How do I connect a database?

Add MySQL or PostgreSQL on the Services screen, then choose Add to site. Short Leash writes DATABASE_URL into the project's .env, with Rails's mysql2:// scheme for MySQL. Rails reads DATABASE_URL once the .env is loaded, for example with the dotenv gem; otherwise set it as a site environment variable.

Why does Rails say "Blocked hosts"?

In development, Rails only answers localhost and IP addresses unless you allow more. Add this to config/environments/development.rb:

config.hosts << ".test"

HTTPS needs nothing extra. Short Leash's proxy sends X-Forwarded-Proto, and Rails trusts it from 127.0.0.1, so request.ssl? and generated URLs use https.