January 27, 2020
So, you want to start developing with Ruby on Rails and React JS in your MacOS machine? Let me give you a step-by-step guide on how you can setup your machine.
What are we installing?
(We won’t be setting up React individually. We’ll use React within a Rails install.)
You can go the usual route of setting up Rails, Postgresql, without using Docker. There are already many resources out there how to do this. Here’s a list of some that you can follow:
Whether you’ll be joining or following FullStack bootcamp, you can use these guides if you want a simple Rails install with Postgresql.
If you haven’t installed Xcode yet, this is the first step you need to do.
It’s as easy as going to the App Store
and downloading XCode.
Or, in the terminal:
$ xcode-select --install
After installing Xcode, we will download macOS’ package manager, Homebrew.
Open up a terminal and put this in:
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Test it out by downloading wget
, which we also need.
$ brew install wget
NVM is Node JS’ version manager. With NVM, you can switch Node versions on the fly. It also automatically does some setup steps for you.
Both Ruby on Rails and React JS requires Node Js installed.
Let’s install nvm first:
$ brew install nvm
Next, create a directory for nvm:
$ mkdir ~/.nvm
We also need to add a few lines to ~/.bash_profile
to make nvm executable:
$ export NVM_DIR=~/.nvm$ source $(brew --prefix nvm)/nvm.sh
Running nvm -v
should yield you the ff:
as-MacBook-Pro:fullstack-web marcdagatan$ nvm -vNode Version Manager (v0.35.1)# More info about Node Version Manager
Now that we have NVM set up, let’s install Node v12.14:
$ nvm install 12.14
To see installed Node versions:
$ nvm ls
If you have multiple Node versions installed, you can specify which version to use by doing:
$ nvm use 12.14
Node already has its own package manager with npm
, but we prefer using yarn
as it compiles way faster than npm
.
We’ll again use brew to install Yarn:
$ brew install yarn
That’s it! To check for yarn’s successful install:
$ yarn -v# it should yield the version number of Yarnas-MacBook-Pro:fullstack-web marcdagatan$ yarn -v1.21.1
Ahh git, the universal version control system of developers. Yes, we will be needing this a lot.
Let’s first install git, again with brew:
$ brew install git
After that, let’s setup your git config:
# set your name$ git config --global user.name "Your Full Name"$ git config --global user.email "youremail@provider.com"
We will start off the bootcamp using sqlite as our database system. But, moving forward, we will be using Postgresql instead. But, we won’t install it the usual way. Scroll down to the bottom to find out how we’ll setup postgresql.
Install sqlite is as easy as:
$ brew install sqlite3
Ruby has multiple version managers with RVM, or RBenv. We prefer using RVM as it’s more stable.
Let’s first install gpg with brew:
$ brew install gnupg
After that, install the gpg keys:
$ gpg --keyserver hkp://pool.sks-keyservers.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
Once done, install RVM with latest stable version of ruby:
$ \curl -sSL https://get.rvm.io | bash -s stable --ruby
Now that we have Ruby in our machines, let’s now install Rails. We will be using Rails version 5.2.4 throughout the course of our bootcamp, so we’ll install that version of rails.
$ gem install rails -v 5.2.4
Whew. That was a lot of steps to take. And now, we’re finally at the end. We want to see if our setup is correct.
Let’s first create a directory for all the apps we will be making:
$ mkdir ~/apps
Go to the new directory you’ve just made:
$ cd ~/apps
Create a new rails project:
$ rails new myapp
Go inside the project:
$ cd myapp
Start the project:
$ rails server# for the shorthand way$ rails s
On your browser go to: http://localhost:3000
TsekAsia’s development team is an avid fan of Docker, and Foreman.
Docker allows use to containerize our development environments, but we won’t use it for that purpose. We will use docker with docker-compose
so we won’t have to install and setup other dependencies such as postgresql
and redis
.
Foreman is a Procfile-based application manager. It allows us to run multiple services all at the same time. We can run, $ rails s
, $ docker-compose up
, and $ bin/webpack-dev-server start
all at the same time, in one terminal window.
We would like to focus more on learning how to use and harness Ruby on Rails with React to its fullest and mitigate the setup process for your development environment. This will also lessen setup time for each individual projects. This would mean, we could focus more on the lessons at hand.
(This is also our Engineering team’s development environment. Following these steps would not only give you a leaner development environment, you’ll also know some trade secrets on how to make your life easier.)
If you will be using Docker for your dev environment, please do not install postgresql through,
$ brew install postgresql
as this will conflict with the docker instance of postgresql. Specifically, your machine will prioritize allocation of port 5432 to your local postgreql install.
With this, let’s go ahead and set up other development dependencies!
Docker already has this guide in their website and it’s comprehensive enough that I don’t need to explain it here. But, Here’s the link to their setup guide for MacOS.
https://docs.docker.com/docker-for-mac/install/
We won’t be using Docker with docker-compose
up until the latter parts of the Bootcamp, but it’s cool to have this installed already so we won’t need to later on.
We won’t be using foreman up until the middle of the bootcamp, but it’s better to have it installed now.
Install foreman by doing this,
$ gem install foreman
Test it out by going to the rails app a rails app, and create a file in your root directory Procfile
with the following contents:
app: rails s
Once saved, run:
$ foreman start
And you’re all good to go!
Marc Dagatan
Chief Technical Officer
FullSuite
FullStack Bootcamp is offering a free coding bootcamp.
What are you waiting for?
Apply now!
Thank you for the overwhelming support!
We've received hundreds of signups and we really appreciate all the love.
We love coffee, do you?
fb.com/BootCampFullStack | ||
linkedin.com/company/campfullstack | ||
fullstackbootcamp@gmail.com |