Open In App

How to Install Ruby on Rails on MacOS?

Improve
Improve
Like Article
Like
Save
Share
Report

Ruby on Rails, also known as rails, is a server-side web application development framework written in the Ruby programming language. David Heinemeier Hansson developed it under the MIT License. It supports MVC (model-view-controller) architecture that provides a default structure for databases, web pages, and web services. It also uses web standards like JSON or XML for transferring data and HTML, CSS, and JavaScript for the user interface. 

Pros for using Ruby on Rails

  • Great for rapid application development (RAD)
  • Battery-included Framework
  • Object-Oriented Nature of Ruby and has a vast collection of open source code available within the Rails community
  • Has good testing frameworks

Cons for using Ruby on Rails

  • Performance and Scalability
  • Not all websites hosts can support Rails
  • Shortage of flexibility 

Download and Installation of Ruby on Rails

macOS usually comes with pre-installed Ruby in its /usr/bin/ruby section.

Pre-installed-ruby

 

However, using this version of ruby is not recommended as it is old, can’t be updated, and installing gems doesn’t work out of the box with the system ruby. This can be done using third-party tools such as rbenv and RVM. This article follows installation through RVM (Ruby Version Manager). 

  • Installing RVM (Ruby Version Manager)

\curl -sSL https://get.rvm.io | bash -s stable

Installing-RVM

Installing RVM 

  • Installing Ruby

rvm use ruby –install–default

Installing-Ruby

Installing a newer version of Ruby and setting it as default

Ruby-installed

 

  • Installing Rails

Ruby gem installations sometimes can be very slow because of the on-the-fly document generation post-process. Thus, it is better to download it without documentation.

gem install rails –no-document

This may take some time as there are many libraries to download. After the installation is complete, restart the terminal. 

Installing-rails-without-document

Location and Version of Rails

  • Running Ruby on Rails Application

To check if we can run the Ruby on Rails application, we can create a trial app and try running this application. 
Choose any preferable location on your Mac and carry out the following commands on your terminal. It may take some time for rails to create a new app. 

mkdir trial-app

cd trial-app/

rails new trialapp

cd trialapp

rails server

Running-ruby-on-rails

Running the rails application through the Command Line

Open the listening port by copying and pasting the URL in the browser or hold the command and click on the link. 

Entering-URL-in-browser

Opening the link in the browser

To stop the application, press Control + C in the terminal. 


Last Updated : 14 Jul, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads