Introduction

Ruby on Rails is a server side web application framework which is written in ruby language. It helps us to build daunting modern web applications much with ease and fun. For data transfer ROR makes use of JSON or XML and for user interface it uses HTML, CSS and Javascript. Ruby on Rails is a MVC (Model View Controller)   Framework. The Model View Controller principle divides the work of an application into three separate but closely cooperative subsystems.
1. Model (Active Record)
2. View (Action View)
3. Controller (Action Controller)

Being an open source project, it also helps Ruby on Rails establish itself as one of the most popular web development tools. These are some of the top famous websites built with Ruby on Rails. E.g. Twitter, Basecamp, Hulu, Slideshare, Github, Shopify, Groupon etc

What Ruby on Rails actually means?
ror

Let’s understand this first,
Ruby: It is a High level programming language with successful combination of smalltalk, python and Perl.

Rails:  Rails  is  an  extremely  productive  web  application  framework  which  is  written  in  ruby  language by David  Heinemeier . A   web application is at least ten times faster with Rails than any other framework. Database backed web applications   are   developed using rails framework.

Rails is a Full Stack Framework: All layers are built to work seamlessly with less coding. Using Model-View-Controller pattern database-driven web application, are created.

Convention over Configuration:  Rails   avoid   configuration   files in favour of conventions, reflection, and dynamic runtime extensions. Whatever Rails needs to know is already present in   application code and your running database.

umang_india

Rails Strength
1. Metaprogramming

Instead of writing code from scratch, Rails framework uses   metaprogramming techniques. Ruby is one of the best languages for metaprogramming, and Rails uses this capability very well. Rails also uses code generation but relies much more on metaprogramming for the heavy lifting.

2. Active Record
Rails introduce the Active Record framework, which saves objects into the database. The Rails version of the Active Record discovers the columns in a database schema and automatically attaches them to your domain objects using   metaprogramming.

3. Scaffolding
You often create temporary code in the early stages of development to help get an application up quickly and see how major components work together. Rails automatically create much of the scaffolding you’ll need.

4. Built-in testing
Rails create simple automated tests you can then extend. Rails also provide supporting code called harnesses and fixtures that make test cases easier to write and run. Ruby can then execute all your automated tests with the rake utility.

5. Three environments
Rails give you three default environments: development, testing, and production. Each behaves slightly differently, making your entire software development cycle easier

Ruby on Rails Installation on Windows
To use Ruby on Rails framework, install the following software’s:
1. Ruby
2. The Rails Framework
3. A Web Server
4. A Database System

Initially you need to install webserver and database on your system.
You can use the WEBrick Web Server, which comes with Ruby or you can go for Apache or lightTPD web server.
Rails work with many database systems like MYSQL, PostgresSQL, SQLite, Oracle, DB2 and SQL server.

Follow the steps given below for installing Ruby on Rails.
Step 1: Check Ruby Version
The command to check if ruby is already installed on your system is
Type “ruby –v”. You will see a version number, then type “gem –version”.

Step 2: Install Ruby
If ruby is not installed on your system than download an installation package from rubyinstaller.org and run it.  You’ll get Ruby gems along with this package.

Step 3: Install Rails
Install Rails − With Ruby gems loaded, you can install all of Rails and its dependencies using the following command,
“C:\>  gem install rails ”

Step 4: Check Rails Version
Command to check the rails version.
C:\> rails –v ”

Workflow for Creating Rails Applications
A recommended work flow for creating Rails Application is as follows.
1. Rails command is used to create the basic application skeleton.
2. Create a database on the server to hold your data.
3. Configure the application to know where your database is located and the login credentials for it.
4. Create Rails Active Records (Models), because they are the business objects you’ll be working with in your controllers.
5. Generate Migrations that simplify the creating and maintaining of database tables and columns.
6. Write Controller Code to put a life in your application.
7. Create Views to present your data through User Interface.

Sample   Ruby   Code
Here is a sample Ruby code to print “Hello Ruby”

blog_2


Embedded Ruby(ERB)
ERP allows you to put Ruby code inside an HTML file. ERB reads word for word and when it come across Ruby code embedded in the document, it starts executing Ruby Code.

Syntax:
1. To execute your Ruby code ,enclose it between <% and %>
2. To print the result of the execution, enclose the code between <%= and %>.


Latest Trends in Ruby on Rails:
1. Use faster globs for template resolving
2. Doing less work and less memory usage
3. Improvement in the performance
4. Default to utf8mb4 for MySQL
5. Introduction of model-level configuration for filtering sensitive attributes
6. Introduction of configurable prefix for Active Storage routes
7. Inclusion of an ID in Action Cable’s Redis configuration
8. Support for read replica database configurations
9.Reduce allocations during parameter filtering.
10.Clear mutation tracker after yielding in around callbacks.
11.Finding inverse associations with plural names

Rails 5.2.1 have been released on 7 August 2018.
The above version consists of the following features:

1.Better error handling of active storage adapters
Now, the Active Storage service adapter names can be lower case or upper case. Also, a nice error message is printed if the service adapter class can’t be loaded.

2. Support for skipping caching of nil entries
While caching data from external services, sometimes we may get nil values. Most probably we don’t want to cache them. Here is an option skip nil: true/false to skip caching of such entries.

ROR Issues
Although we have many reasons to use Ruby, there are a few drawbacks as well that you may have to consider before implementing Ruby.
Performance Issues− Although it rivals Perl and Python, it is still an interpreted language and we cannot compare it with high-level programming languages like C or C++.
Threading model− Ruby does not use native threads. Ruby threads are simulated in the VM rather than running as native OS threads.

 

References:  https://www.tutorialspoint.com/ruby-on-rails
                       https://weblog.rubyonrails.org/
                       https://en.wikipedia.org/wiki/Ruby_on_Rails