Rails - New Commands

The rails new command is used to create a new Ruby on Rails application. It generates a basic directory structure and configuration for the application, and installs a number of default dependencies.

By default, the rails new command creates a new Git repository for the application, and includes a number of default configuration files and directories, such as a Gemfile, a database configuration file, and an assets directory. It also installs a number of default gems, including Rails itself, as well as other libraries such as Puma (a web server), Spring (an application preloader), and Turbolinks (a JavaScript library for improving navigation performance).

The rails new command accepts a number of options that allow you to customize the structure and configuration of the application. Some of the options available include the commands listed below.

Create a Rails App Skip Creating a Default Gemfile

The rails new example_app --skip-gemfile command creates a new Ruby on Rails application with the name example_app, and the --skip-gemfile flag tells Rails to skip creating the default Gemfile for the application.

The Gemfile is a file that specifies the gem dependencies for your Rails application. It's used by the Ruby package manager bundler to install all of the required gems for your application. By skipping the creation of the Gemfile, you will need to manually specify the gems that your application depends on.

Keep in mind that skipping the Gemfile can make it more difficult to manage the dependencies for your application, as you will need to manually specify and install all of the required gems. You may want to consider using the default Gemfile and adding any additional gems that your application needs as needed.

Create a Rails App Skip Creating a Git Repository Configuration Files

The rails new example_app --skip-git command creates a new Ruby on Rails application with the name example_app, and the --skip-git flag tells Rails to skip creating a Git repository for the application.

By default, Rails will initialize a Git repository for your application and create an initial commit with the files generated by the rails new command. If you use the --skip-git flag, Rails will not create a Git repository for your application, and you will need to manually initialize a repository and make your initial commit if you want to use Git for version control.

Keep in mind that using Git for version control can be a useful tool for tracking changes to your application and collaborating with others. You may want to consider using Git for your application, even if you don't use the default Gemfile or the default Git repository initialization.

Create a Rails App Skip Creating the ActionMailer Configuration Files

The rails new example_app --skip-action-mailer command creates a new Ruby on Rails application with the name example_app, and the --skip-action-mailer flag tells Rails to skip the Action Mailer files.

Action Mailer is a Rails component that allows you to send and receive emails from your application. It provides a convenient interface for creating and sending email messages, as well as a number of tools for handling email delivery and receipt. By skipping the Action Mailer files, you will not have access to these features in your application.

Keep in mind that Action Mailer is a useful tool for many types of applications, and you may want to consider including it in your application even if you don't use the default Gemfile or the default Git repository initialization. If you do decide to use Action Mailer, you can add it to your application by running the rails generate action_mailer:install command. This will create the necessary files and configure your application to use Action Mailer.

Create a Rails App Skip Creating the ActionText Configuration Files

The rails new example_app --skip-action-text command creates a new Ruby on Rails application with the name example_app, and the --skip-action-text flag tells Rails to skip the Action Text files.

Action Text is a Rails component that allows you to include rich text content and formatting in your application. It provides a convenient interface for creating and editing rich text content, as well as tools for storing and displaying that content in your application. By skipping the Action Text files, you will not have access to these features in your application.

Keep in mind that Action Text can be a useful tool for many types of applications, and you may want to consider including it in your application even if you don't use the default Gemfile or the default Git repository initialization. If you do decide to use Action Text, you can add it to your application by running the rails action_text:install command. This will create the necessary files and configure your application to use Action Text.

Create a Rails App Skip Creating the ActiveRecord Configuration Files

The rails new example_app --skip-active-record command creates a new Ruby on Rails application with the name example_app, and the --skip-active-record flag tells Rails to skip the Active Record files.

Active Record is the default object-relational mapper (ORM) in Rails, and it provides a convenient interface for interacting with a database from your application. It allows you to define models that correspond to database tables, and provides a number of tools for querying and manipulating data in the database. By skipping the Active Record files, you will not have access to these features in your application.

Keep in mind that Active Record is a useful tool for many types of applications, and you may want to consider including it in your application even if you don't use the default Gemfile or the default Git repository initialization. If you do decide to use Active Record, you can add it to your application by running the rails active_record:install command. This will create the necessary files and configure your application to use Active Record.

If you don't want to use Active Record, you can use an alternative ORM such as Sequel or DataMapper. Alternatively, you can also use a lower-level database library such as SQLite3 or MySQL directly to interact with the database from your application.

Create a Rails App Skip Creating the ActiveStorage Configuration Files

The rails new example_app --skip-active-storage command creates a new Ruby on Rails application with the name example_app, and the --skip-active-storage flag tells Rails to skip the Active Storage files.

Active Storage is a Rails component that allows you to manage file attachments in your application. It provides a convenient interface for uploading and storing files, as well as tools for managing and displaying those files in your application. By skipping the Active Storage files, you will not have access to these features in your application.

Keep in mind that Active Storage can be a useful tool for many types of applications, and you may want to consider including it in your application even if you don't use the default Gemfile or the default Git repository initialization. If you do decide to use Active Storage, you can add it to your application by running the rails active_storage:install command. This will create the necessary files and configure your application to use Active Storage.

If you don't want to use Active Storage, you can use an alternative file storage solution such as Amazon S3 or Google Cloud Storage. Alternatively, you can also store files directly on the file system of your application server.

Create a Rails App Skip Creating Puma Configuration Files

The rails new example_app --skip-puma command creates a new Ruby on Rails application with the name example_app, and the --skip-puma flag tells Rails to skip the Puma configuration files.

Puma is a popular Ruby web server that is often used with Rails applications. It is fast and efficient, and is well-suited to handling high levels of concurrency. By default, Rails will create a Puma configuration file (config/puma.rb) and a Puma service file (config/puma.service) when you create a new application.

If you use the --skip-puma flag, Rails will not create these files, and you will need to manually configure Puma if you want to use it as the web server for your application. Keep in mind that Puma is a useful tool for many types of applications, and you may want to consider using it even if you don't use the default Gemfile or the default Git repository initialization.

If you don't want to use Puma, you can use an alternative web server such as Unicorn or Thin. Alternatively, you can also use a more full-featured web server such as Apache or Nginx in combination with a Ruby web server gateway such as Phusion Passenger.

Create a Rails App Skip Creating the ActionCable Configuration Files

The rails new example_app --skip-action-cable command creates a new Ruby on Rails application with the name example_app, and the --skip-action-cable flag tells Rails to skip the Action Cable files.

Action Cable is a Rails component that allows you to build real-time, bidirectional communication between the server and clients in your application. It provides a convenient interface for creating WebSockets connections and handling real-time messages, and is often used to build chat applications, notifications, and other real-time features. By skipping the Action Cable files, you will not have access to these features in your application.

Keep in mind that Action Cable can be a useful tool for many types of applications, and you may want to consider including it in your application even if you don't use the default Gemfile or the default Git repository initialization. If you do decide to use Action Cable, you can add it to your application by running the rails generate action_cable:install command. This will create the necessary files and configure your application to use Action Cable.

Create a Rails App Skip Creating the Sprockets Configuration & Related Asset Files

The rails new example_app --skip-sprockets command creates a new Ruby on Rails application with the name example_app, and the --skip-sprockets flag tells Rails to skip the Sprockets files.

Sprockets is a Ruby library for compiling and serving web assets, such as JavaScript, CSS, and images. It is often used with Rails applications to manage the assets for the application. By default, Rails will create a number of Sprockets configuration files when you create a new application, including config/initializers/assets.rb and config/assets.rb.

If you use the --skip-sprockets flag, Rails will not create these files, and you will not have access to the default Sprockets configuration for your application. Keep in mind that Sprockets can be a useful tool for many types of applications, and you may want to consider using it even if you don't use the default Gemfile or the default Git repository initialization.

If you don't want to use Sprockets, you can use an alternative asset management solution such as Webpack or Parcel. Alternatively, you can also manage your assets manually by serving them directly from the file system of your application server.

Create a Rails App Skip Creating the Spring Preloader Configuration Files

The rails new example_app --skip-spring command creates a new Ruby on Rails application with the name example_app, and the --skip-spring flag tells Rails to skip the Spring application preloader.

Spring is a Rails application preloader that speeds up the startup time of your Rails applications by keeping a long-running instance of your application running in the background. When you start your application, Spring will first check to see if there is already an instance running, and if there is, it will simply reuse that instance rather than starting a new one. This can significantly reduce the startup time of your application, especially if you are running a large or complex application.

By default, Rails will create a Spring configuration file (config/spring.rb) when you create a new application, and will also include the Spring gem in the Gemfile. If you use the --skip-spring flag, Rails will not create the Spring configuration file, and will not include the Spring gem in the Gemfile.

Keep in mind that Spring can be a useful tool for speeding up the development of your Rails applications, and you may want to consider using it even if you don't use the default Gemfile or the default Git repository initialization. If you do decide to use Spring, you can add it to your application by running the rails generate spring:install command. This will create the necessary configuration file and include the Spring gem in the Gemfile.

Create a Rails App Skip Creating the TurboLinks Configuration Files

The rails new example_app --skip-turbolinks command creates a new Ruby on Rails application with the name example_app, and the --skip-turbolinks flag tells Rails to skip the Turbolinks configuration.

Turbolinks is a JavaScript library that speeds up navigation in Rails applications by replacing the entire body of the page with the new content when you follow a link, rather than reloading the entire page. This can significantly improve the performance of your application, especially on mobile devices. By default, Rails includes Turbolinks in new applications, and adds the necessary JavaScript and CSS files to enable it.

If you use the --skip-turbolinks flag, Rails will not include the Turbolinks JavaScript and CSS files, and will not configure your application to use Turbolinks. Keep in mind that Turbolinks can be a useful tool for improving the performance of your Rails applications, and you may want to consider using it even if you don't use the default Gemfile or the default Git repository initialization.

If you do decide to use Turbolinks, you can add it to your application by running the rails generate turbolinks:install command. This will include the necessary JavaScript and CSS files and configure your application to use Turbolinks.

Alternatively, if you don't want to use Turbolinks, you can disable it by removing the turbolinks gem from the Gemfile and removing the data-turbolinks-track attribute from the head tag in the application.html.erb layout file.

Create a Rails App Skip Creating the System Test Configuration Files

The rails new example_app --skip-system-test command creates a new Ruby on Rails application with the name example_app, and the --skip-system-test flag tells Rails to skip the system test configuration files.

System tests are a type of automated test that simulate the behavior of a user interacting with your application in a browser. They are designed to test the overall functionality of your application, and are typically used to catch regressions and ensure that your application is working correctly. By default, Rails creates a system test configuration file (config/application_system_test_case.rb) and a system test directory (test/system) when you create a new application.

If you use the --skip-system-test flag, Rails will not create these files, and you will not have access to the default system test configuration for your application. Keep in mind that system tests can be a useful tool for testing the overall functionality of your Rails applications, and you may want to consider using them even if you don't use the default Gemfile or the default Git repository initialization.

If you do decide to use system tests, you can add them to your application by running the rails generate system_test command. This will create the necessary.