Ruby on Rails Hello World
Ruby on Rails (RoR) is a web application development MVC framework built on Ruby language. It is open source and cross platform. MVC is the acronym for Model View Controller. It is a design pattern that separates the data (Model) from the presentation (View). The Models and Views are glued together using Controllers.
Ruby is an object oriented programming language. Since ruby on rails is built on ruby language, you can take full advantage of object oriented programming when working with ruby on rails.
Topics to be covered
We will cover the following topic in these tutorial series.
- How MVC frameworks work
- Features of Ruby on rails that make it superb
How MVC frameworks work
The following diagram shows how the MVC architecture works
- 1 Web browser – visitors use web browsers to interact with the web server. The web server sends the HTTP requests to the server.
- 2a Controller – the controller glues models and views together. The controller can also interact with the model if necessary to retrieve data.
- 2b Models – the model is responsible for interacting with data sources i.e. databases, APIs, flat files etc. The model returns the retrieved data to the controller.
- Controller – the controller is responsible for loading the view. The controller can also pass data from the model to the view.
- Views – views are responsible for presentation, the HTML that is returned to the browser.
Features of Ruby on rails that make it superb
Ruby on rails is an MVC framework so advantages inherit to the MVC architecture also apply to ruby. We will not list such advantages in this section. Below are some of the features that are more specific to ruby on rails.
- Convention over configuration – conventions are like agreed upon ways of doing things. For example, a database table name is expected to be plural, it is also expected to have an auto generated primary key named id etc. Ruby on rails calls these sensible defaults. If you follow this conversion, then you don’t need to configure a table name or specify an auto increment column named id for your tables. It is recommend to follow conversions over configuration. Should you have good reason not to use sensible defaults, you can still configure ruby on rails
- Rapid Application Development – convention over configuration leads to writing less code and speeds up application development.
- Short learning curve due to simple and easy to read syntax – Ruby in rails has a very simple syntax. You don’t have to end all statements with semi colons like in most languages that were derived from
- Ruby on rails is built on don’t repeat yourself (DRY) principle. Naturally, it encourages you to write DRY code
The following are the pre-requisites for learning ruby on rails
- Web browser – you will need to execute your code as you develop and see the output.
- Web server – the web server is responsible for handling HTTP requests and returning the responses.
- SQL – SQL is the acronym for Structured Query Language. It is used to query databases. Ruby on rails’ ActiveRecord actually writes the SQL statements for you but it’s an advantage when you know what is going on behind the scenes.
- Programming basics – this is not mandatory but if you are familiar with programming principles then it will be easier for you to learn ruby on rails
- Ruby language – this is an added advantage.
Ruby on rails is a powerful MVC framework that speeds up developing web applications. It has a short learning curve and it’s an open source framework.Ruby on rails is a powerful
These tutorial series are designed to teach you how to program using ruby on rails from scratch and transform you into a professional ruby on rails developer.
If you found this tutorial useful, support us by using the social media buttons to like and share the tutorial. If you didn’t find it useful, please use the comments section below to let us know how we can do better next time.
Each week, a new Ruby on Rails tutorial is added to our collection. Subscribe to our newsletter, like our Facebook fan page or follow us on Twitter to get free updates when the collection is updated.
Tutorial version 1: Date Published 2015-09-21