Using Rails main for Development

This post covers how to run on Rails main rather than a released version for developing your web application.

Creating a new Rails App

The way to create a new Rails app on edge is to add the --main flag when you create a new Rails app.

$ rails new app_on_main --main --skip-test --javascript=esbuild --css=tailwind --database=sqlite3

You’ll see a lot of text fly by as it sets things up.

$ rails new app_on_main --main --skip-test --javascript=esbuild --css=tailwind --database=sqlite3
      create  Gemfile
         run  bundle install
Updating files:  33% (1564/4668)
Updating files:  34% (1588/4668)
Updating files:  35% (1634/4668)
Updating files:  36% (1681/4668)
Updating files:  37% (1728/4668)
Updating files:  38% (1774/4668)
Updating files:  39% (1821/4668)
Updating files:  40% (1868/4668)
Updating files:  41% (1914/4668)
Updating files:  42% (1961/4668)
Updating files:  43% (2008/4668)
Updating files:  44% (2054/4668)
Updating files:  45% (2101/4668)
Updating files:  46% (2148/4668)
Updating files:  47% (2194/4668)
Updating files:  48% (2241/4668)
Updating files:  49% (2288/4668)
Updating files:  50% (2334/4668)
Updating files:  51% (2381/4668)
Updating files:  52% (2428/4668)
Updating files:  53% (2475/4668)
Updating files:  54% (2521/4668)
Updating files:  55% (2568/4668)
Updating files:  56% (2615/4668)
Updating files:  57% (2661/4668)
Updating files:  58% (2708/4668)
Updating files:  59% (2755/4668)
Updating files:  60% (2801/4668)
Updating files:  61% (2848/4668)
Updating files:  62% (2895/4668)
Updating files:  63% (2941/4668)
Updating files:  64% (2988/4668)
Updating files:  65% (3035/4668)
Updating files:  65% (3080/4668)
Updating files:  66% (3081/4668)
Updating files:  67% (3128/4668)
Updating files:  68% (3175/4668)
Updating files:  69% (3221/4668)
Updating files:  70% (3268/4668)
Updating files:  71% (3315/4668)
Updating files:  72% (3361/4668)
Updating files:  73% (3408/4668)
Updating files:  74% (3455/4668)
Updating files:  75% (3501/4668)
Updating files:  76% (3548/4668)
Updating files:  77% (3595/4668)
Updating files:  78% (3642/4668)
Updating files:  79% (3688/4668)
Updating files:  80% (3735/4668)
Updating files:  81% (3782/4668)
Updating files:  82% (3828/4668)
Updating files:  83% (3875/4668)
Updating files:  84% (3922/4668)
Updating files:  85% (3968/4668)
Updating files:  86% (4015/4668)
Updating files:  87% (4062/4668)
Updating files:  88% (4108/4668)
Updating files:  89% (4155/4668)
Updating files:  90% (4202/4668)
Updating files:  91% (4248/4668)
Updating files:  92% (4295/4668)
Updating files:  92% (4297/4668)
Updating files:  93% (4342/4668)
Updating files:  94% (4388/4668)
Updating files:  95% (4435/4668)
Updating files:  96% (4482/4668)
Updating files:  97% (4528/4668)
Updating files:  98% (4575/4668)
Updating files:  99% (4622/4668)
Updating files: 100% (4668/4668)
Updating files: 100% (4668/4668), done.
Resolving dependencies...
Fetching gem metadata from
Fetching reline 0.5.2
Installing reline 0.5.2
Bundle complete! 1 Gemfile dependency, 58 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
         run  bundle exec rails new d:/projects/rails/trial/app_on_main --main --skip-test --javascript\=esbuild --css\=tailwind --database\=sqlite3
      remove  Gemfile
      remove  Gemfile.lock
      create  Rakefile
      create  .ruby-version
      create  .gitignore
      create  .gitattributes
      create  Gemfile
         run  git init from "."
Initialized empty Git repository in D:/projects/rails/trial/app_on_main/.git/
      create  app
      create  app/assets/config/manifest.js
      create  app/assets/stylesheets/application.css
      create  app/channels/application_cable/channel.rb
      create  app/channels/application_cable/connection.rb
      create  app/controllers/application_controller.rb
      create  app/helpers/application_helper.rb
      create  app/jobs/application_job.rb
      create  app/mailers/application_mailer.rb
      create  app/models/application_record.rb
      create  app/views/layouts/application.html.erb
      create  app/views/layouts/mailer.html.erb
      create  app/views/layouts/mailer.text.erb
      create  app/views/pwa/manifest.json.erb
      create  app/views/pwa/service-worker.js
      create  app/assets/images
      create  app/assets/images/.keep
      create  app/controllers/concerns/.keep
      create  app/models/concerns/.keep
      create  bin
      create  bin/brakeman
      create  bin/rails
      create  bin/rake
      create  bin/rubocop
      create  bin/setup
      create  Dockerfile
      create  .dockerignore
      create  bin/docker-entrypoint
      create  .rubocop.yml
      create  .github/workflows
      create  .github/workflows/ci.yml
      create  .github/dependabot.yml
      create  config
      create  config/routes.rb
      create  config/application.rb
      create  config/environment.rb
      create  config/cable.yml
      create  config/puma.rb
      create  config/storage.yml
      create  config/environments
      create  config/environments/development.rb
      create  config/environments/production.rb
      create  config/environments/test.rb
      create  config/initializers
      create  config/initializers/assets.rb
      create  config/initializers/content_security_policy.rb
      create  config/initializers/cors.rb
      create  config/initializers/enable_yjit.rb
      create  config/initializers/filter_parameter_logging.rb
      create  config/initializers/inflections.rb
      create  config/initializers/new_framework_defaults_7_2.rb
      create  config/initializers/permissions_policy.rb
      create  config/locales
      create  config/locales/en.yml
      create  config/master.key
      append  .gitignore
      create  config/boot.rb
      create  config/database.yml
      create  db
      create  db/seeds.rb
      create  lib
      create  lib/tasks
      create  lib/tasks/.keep
      create  lib/assets
      create  lib/assets/.keep
      create  log
      create  log/.keep
      create  public
      create  public/404.html
      create  public/406-unsupported-browser.html
      create  public/422.html
      create  public/500.html
      create  public/icon.png
      create  public/icon.svg
      create  public/robots.txt
      create  tmp
      create  tmp/.keep
      create  tmp/pids
      create  tmp/pids/.keep
      create  vendor
      create  vendor/.keep
      create  storage
      create  storage/.keep
      create  tmp/storage
      create  tmp/storage/.keep
      create  .devcontainer
      create  .devcontainer/devcontainer.json
      create  .devcontainer/Dockerfile
      create  .devcontainer/compose.yaml
      remove  config/initializers/cors.rb
      remove  config/initializers/new_framework_defaults_7_2.rb
         run  bundle install --quiet
         run  bundle lock --add-platform=x86_64-linux
Fetching gem metadata from
Resolving dependencies...
Writing lockfile to d:/projects/rails/trial/app_on_main/Gemfile.lock
         run  bundle binstubs bundler
       rails  importmap:install
       apply  D:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/importmap-rails-2.0.1/lib/install/install.rb
  Add Importmap include tags in application layout
      insert    app/views/layouts/application.html.erb
  Create application.js module as entrypoint
      create    app/javascript/application.js
  Use vendor/javascript for downloaded pins
      create    vendor/javascript
      create    vendor/javascript/.keep
  Ensure JavaScript files are in the Sprocket manifest
      append    app/assets/config/manifest.js
  Configure importmap paths in config/importmap.rb
      create    config/importmap.rb
  Copying binstub
      create    bin/importmap
         run  bundle install --quiet
       rails  turbo:install stimulus:install
       apply  D:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/turbo-rails-2.0.5/lib/install/turbo_with_importmap.rb
  Import Turbo
      append    app/javascript/application.js
  Pin Turbo
      append    config/importmap.rb
         run  bundle install --quiet
Run turbo:install:redis to switch on Redis and use it in development for turbo streams
       apply  D:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/stimulus-rails-1.3.3/lib/install/stimulus_with_importmap.rb
  Create controllers directory
      create    app/javascript/controllers
      create    app/javascript/controllers/index.js
      create    app/javascript/controllers/application.js
      create    app/javascript/controllers/hello_controller.js
  Import Stimulus controllers
      append    app/javascript/application.js
  Pin Stimulus
  Appending: pin "@hotwired/stimulus", to: "stimulus.min.js"
      append    config/importmap.rb
  Appending: pin "@hotwired/stimulus-loading", to: "stimulus-loading.js"
      append    config/importmap.rb
  Pin all controllers
  Appending: pin_all_from "app/javascript/controllers", under: "controllers"
      append    config/importmap.rb
         run  bundle install --quiet

If you go into the Gemfile, you will see that this is how Rails is set up.

# Use main development branch of Rails
gem "rails", github: "rails/rails", branch: "main"

After this, just use ruby bin\rails [whatever] for your needs.

$ ruby bin\rails s
=> Booting Puma
=> Rails 7.2.0.alpha application starting in development
=> Run `bin/rails server --help` for more startup options
*** SIGUSR2 not implemented, signal based restart unavailable!
*** SIGUSR1 not implemented, signal based restart unavailable!
*** SIGHUP not implemented, signal based logs reopening unavailable!
Puma starting in single mode...
* Puma version: 6.4.2 (ruby 3.3.0-p0) ("The Eagle of Durango")
*  Min threads: 3
*  Max threads: 3
*  Environment: development
*          PID: 2976
* Listening on http://[::1]:3000
* Listening on
Use Ctrl-C to stop

If you go to http://localhost:3000/ you will see the Rails welcome page.

Updating Rails

If you need to do an update, just go ahead and do:

$ gem update rails

Enjoy programming with Rails.

One issue

If you use this on Windows, you might encounter a Rubocop issue – see this post for the details and the fix for now.

comments powered by Disqus