Quick Guide To Deploy Ruby On Rails Web Application

Posted By :Mahendra Singh |27th August 2020

Deploy Ruby On Rails Web Application

 

Rails is a server-side web application framework written in ruby language. It is a web development tool that adds backend and frontend skills. It allows developers to deploy and write less code compared to other web-frameworks. Rails have everything which needs to create a database-backend web application. Rails offer to handle routing, data, asset management, etc. In this blog post, we will learn how to deploy Ruby on Rails in easy-to-follow steps. 

 

We, at Oodles, as an evolving Machine Learning Development Company, are constantly experimenting with automation technologies and different programming languages like Ruby, Python, Java, and more to build resilient AI solutions. 
 

Principles of Rails

 

There are two basic principles of rails as given below-

 

1. Don't Repeat Yourself – It allows us to not writing the same code over and over again. by this, our code is more maintainable and more extensible.

2. Convention Over Configuration – Rails can make effective assumptions about what a programmer wishes to do and his way of doing it.


 

Rail is a model–view–controller (MVC) framework to create a database-backend web application. Important Key to understanding the rails we have to first understand the MVC pattern which divides your application into three layers:

 

   (a) Model (A model represents the information data such as a person, product, company, etc.. )

   (b) View ( layer used to representations of your application's resources or it represent the user interface) 

   (c) Controller (make the bond between model and view and controls the process and  responsible for browser activity)

 

 Deploying an Existing Ruby on  Rails App from Version control system :

  

 Prerequisites: The server should be set up with given Prerequisites.

 

  • A non-root user with admin privileges and a firewall configured.
  • Node js with PPA.
  • Ruby and rbenv/rvm , rails.
  • Install MySQL server & client and create a user and set a password for it.
  •  

Follow the below steps to configure and deploy your app.

Step1: check the required software and Update the gem.

 


   node -v
  mysql -V
  ruby -v
  sudo gem update --system
  gem -v

 

 

Step2: install bundler to install bundles for the project app.

 


  gem install bundler
  bundle -v

 

Steps3: Pull the project repo from your  VCS.

 


  git clone https://[email protected]/project.git

 

Step4: install and update all the bundles in your project.

 

   cd project/
 bundle install

 

Step5: check rails and if you haven't yet then install it.

 

 


  rails -v
 gem install rails 

  
 

Step6: go to project database config/database.yml and configure it according to your DB details.

 

default: &default
  adapter: mysql2
  encoding: utf8
  pool: 5
  username: root
  password: root 
  host: 127.0.0.1


 

Step7: Now you have your database configured, it's time to have Rails create an empty database and migrate it for you by running below cmd.

 

 


 rake db:create  
 rake db:migrate

 

This will create and migrate your DB according to your previous configuration.

 

Step8: Connection should be allowed on port 3000.

 


   ufw allow 3000/tcp
   

 

 Step9: start the webserver

 

 


 rails s or rails serve
 

 Go to http://localhost:3000 and you'll see your app is running.

  

 Step10: Bind your IP because in the above  It will run the server on localhost and default port 3000


 


  rails server --binding=your_server_ip
 

 

In the above, we can start the server either rails s or rails s --binding=your_server_ip and navigate to your application at either http://localhost:3000 or http://your_server_ip:3000.

 

 

Closing Remarks

As already mentioned above, Rails is a web framework which gives developer to work in a way such as isolated env from users, easier way to develop code and keeping code dry. Here we've deployed a pre-existing project app on bitbucket in a simple way. For better security and performance of the app site, you should configure your rails app using Nginx in the production.



Connect with Oodles, an Artificial Intelligence Development Company, for kickstarting your business automation journey using unique frameworks, programming languages, and libraries.


About Author

Mahendra Singh

Mahendra is a DevOps Engineer with hands-on experience supporting automating and optimizing deployments in AWS, configuration management, and DevOps processes with Ansible, Github, Docker, Python, Nginx, and Linux.

Request For Proposal

[contact-form-7 404 "Not Found"]

Ready to innovate ? Let's get in touch

Chat With Us