rails-new
Create a new Rails application
TLDR
Create a Rails app named blog in the current directory
Create a Rails app with API-only configuration
Create a Rails app with postgresql as the database
Create a Rails app without generating JavaScript files
Display help
SYNOPSIS
rails new application_name [options]
PARAMETERS
application_name
The name of the new Rails application to be created.
-d, [--database=DATABASE]
Specifies the database to use (e.g., `postgresql`, `mysql`, `sqlite3`). Defaults to SQLite.
-G, [--no-skip-git]
Don't skip git initialization.
-m, [--template=TEMPLATE]
Path to a custom application template.
-r, [--ruby=PATH]
Path to the Ruby executable to use.
--api
Preconfigure smaller stack for API apps.
--minimal
Preconfigure smaller stack for minimal apps.
--dev
Setup the application with Gemfile pointing to your local Rails checkout.
--edge
Setup the application with Gemfile pointing to Rails repository on GitHub.
--skip-namespace
Skip namespace (affects only isolated engine apps).
--skip-active-storage
Skip Active Storage.
--skip-action-mailer
Skip Action Mailer.
--skip-action-cable
Skip Action Cable.
--skip-sprockets
Skip Sprockets.
--skip-puma
Skip Puma setup.
--skip-listen
Don't use listen gem.
--skip-javascript
Skip JavaScript files.
--skip-turbolinks
Skip Turbolinks gem.
--skip-test
Skip test files.
--skip-system-test
Skip system test files.
DESCRIPTION
The `rails new` command is a powerful tool in the Ruby on Rails framework used to bootstrap a new Rails application. It automates the process of setting up the basic directory structure, configuration files, and dependencies needed to start developing a web application with Rails.
It creates a fully functional, albeit basic, Rails application that adheres to the Model-View-Controller (MVC) architectural pattern. It handles tasks like creating the `Gemfile` to manage Ruby gems, establishing the initial database configuration, setting up the application layout, and installing core dependencies. You can customize the generated application with various options, such as specifying the database (e.g., PostgreSQL, MySQL, SQLite), using a particular Rails version, or skipping certain features like testing frameworks or JavaScript preprocessors. The Rails command is essential for rapidly starting new web projects with the Rails framework.
TEMPLATES
Rails templates are Ruby files that can be used to automate various tasks during the application creation process. They can be used to install gems, configure settings, or even generate initial code. Using a template with `rails new` can significantly speed up the setup of a new Rails application tailored to specific needs.
HISTORY
The `rails new` command was introduced with the Ruby on Rails framework. Its primary purpose has remained consistent: to automate the creation of new Rails applications. Over time, it has been enhanced with more options and customizations to provide greater flexibility to developers. The evolution of the command reflects the ongoing development of the Rails framework itself.