You’re gonna start a new project using Ruby on Rails? Nice choice I’d say!
The main goal of this post is to provide a solid start for a general purpose project and to prevent hours of refactoring.
First things first: Ruby version
I personally prefer
rbenv, but pick your favorite tool.
To choose the Ruby version you should check the latest official release and install it using your ruby version manager:
$ rbenv install 3.1.2
Great! Now validate that you’re using the latest version:
$ ruby -v
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-darwin19]
Next natural step is to install the latest version of Rails.
$ gem install rails -v 7.0.4
And again validate version was installed correctly:
$ rails -v
Creating the project
Now the juice!
There are many options to start a new Rails project, but there are 2 that are considered more important and that hopefully will follow you throughout the project’s lifetime.
database, there’s no safer option than PostgreSQL.
And for the
test framework, the Ruby on Rails community has adopted Rspec as it’s favorite testing tool.
Now, with those options in mind, let’s create the project:
$ rails new my_awesome_project --skip-test -d postgresql
As you can see, there’s no option to select
Rspec as the
test framework in
rails new command, so we’ll have to install it afterwards.
And that’s it for this post!
In sequence I’ll write how to install
rspec-rails and other
gems that can help in your Rails journey ;)