How to Install Ruby on Rails on MacOS?
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.
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
rvm use ruby –install–default
Installing a newer version of Ruby and setting it as default
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.
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 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.
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
Share your thoughts in the comments
Please Login to comment...