Installing Ruby on Rails Development Environment on Mac OS

In this post, I will give show the commands to install Ruby on Rails Development Environment on Mac OS

Installing Ruby on Mac

Source: https://github.com/rbenv/rbenv

brew install rbenv
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
source ~/.bash_profile
rbenv install --list # To list the versions that you can install
rbenv install 3.0.2
rbenv global 3.0.2

Installing PostgreSQL on Mac

Source: https://formulae.brew.sh/formula/postgresql

brew install postgresql
brew services start postgresql
psql -h localhost -d postgres

Installing Ruby on Rails and Creating a Website

sudo gem install rails
rails new blog --database postgresql --skip-git --skip-turbolinks --skip-bootsnap --skip-spring --skip-action-text --skip-webpack-install
Configure
config/database.yml
by adding the host of the database to to the development environment. Then run
rake db:create
to create the database

Adding your first model to the application

bin/rails generate scaffold Post title:string body:text
rake db:migrate

Start your application server

./bin/rails s

Install Redis and add the gem

brew update
brew install redis
brew services start redis

Add

gem 'redis'
to your Gemfile and run
bundle install
Validate this by running
rails console
and run a command like
Redis.new.dbsize
. It should return 0


About Me

My name is Omar Qunsul. I write these articles mainly as a future reference for me. So I dedicate some time to make them look shiny, and share them with the public.

You can find me on twitter @OmarQunsul, and on Linkedin.


Homepage