How to quickly get your rails app up and running
When starting on a new project that uses Ruby on Rails, it’s helpful to understand the different options available to spinning up a new rails application.
Make sure Rails is installed
If you haven’t installed Ruby on Rails globally, you’ll need to make sure the gem is installed, first check which version of Rails you have:
rails -v 7.0.4
If you don’t have it installed, use the gem command:
gem install rails
Spinning up a new app
The simplest way of creating a new rails application is through the command:
rails new grocerylist
This will take a few minutes, but you’ll have a fresh installation of rails setup.
One thing to keep in mind is that rails will generate a new application with whatever the global version of rails that’s installed on your machine.
Install with Presets
There’s a few command line shortcuts you can use to speed up the process of setting up a new Rails project.
You can easily setup your new Rails application with a database ORM of your choice. As an example, you can install the grocerylist project with Postgres:
rails new grocerylist --database=postgresql
A few other database options:
If you plan on using Rails as a backend API only, then you’ll want to use the
--api flag. This removes several middleware options that are normally used with frontend applications as part of Rails.
rails new example-api --api
If you want to skip certain dependencies you can pass the
--skip to slim down the project. As an example, you can skip running bundle install to speed up the initial install:
rails new app --skip-bundle
To see the full list of skip fields run:
rails new --help
What are you waiting for!?
Ruby on Rails is a powerful open source web framework used by many commercial products. It all starts with a new project, and it’s super easy to build your shiny new app with the command line utility that ships with Rails.