Ruby on Rails Framework - Ruby on Rails

What us Ruby on Rails Framework?

A framework is a program, set of programs, and/or code library that writes most of the general things of your application for you. When you use a framework, you just have to write the parts of the application that make it do the specific things you want. The three primary tasks, apart from configuration and other housekeeping chores, when you are set out to write a Rails application, are −

  • Understanding the domain − The first thing to do is to figure out the domain, whch is the universe of your application. It can be anything like a music store, a university, a dating service, an address book, or a hardware inventory. Figure out what's in it, what entities exist in this universe and how the items in it relate to each other, just like modeling a database structure to keep the entities and their relationship.
  • Specify what can happen in this domain − The domain model has to be made dynamic from static. Addresses can be added to an address book. Musical scores can be purchased from music stores. Users can log in to a dating service. Students can register for classes at a university. Identify and address all the possible scenarios or actions that the elements of your domain can participate in.
  • Choose and design the publicly available views of the domain − Now, start thinking in Web-browser terms. Once you've decided that your domain has students, and that they can register for classes, you can envision a welcome page, a registration page, and a confirmation page, etc. Each of these pages, or views, shows the user how things stand at a certain point.

Ruby on Rails deals with a Model/View/Controller (MVC) framework, based on the above three tasks,

What is Ruby on Rails MVC Framework?

The Model View Controller principle divides the work of an application into three separate but closely cooperative subsystems.

Understanding MVC

  • Model (ActiveRecord ) :It maintains the relationship between the objects and the database and handles validation, association, transactions, and more. This subsystem is implemented in ActiveRecord library, which provides an interface and binding between the tables in a relational database and the Ruby program code that manipulates database records. Ruby method names are automatically generated from the field names of database tables.
  • View ( ActionView ) :It is a presentation of data in a particular format, triggered by a controller's decision to present the data. They are script-based template systems like JSP, ASP, PHP, and very easy to integrate with AJAX technology.This subsystem is implemented in ActionView library, which is an Embedded Ruby (ERb) based system for defining presentation templates for data presentation. Every Web connection to a Rails application results in the displaying of a view.
  • Controller ( ActionController ):The facility within the application that directs traffic, on the one hand, querying the models for specific data, and on the other hand, organizing that data (searching, sorting, messaging it) into a form that fits the needs of a given view.

This subsystem is implemented in ActionController, which is a data broker sitting between ActiveRecord (the database interface) and ActionView (the presentation engine).

MVC Framework in pictures

Here is a pictorial representation of Ruby on Rails Framework:

rails framework

How to make a directory Representation of MVC Framework

Assuming a standard, default installation over Linux, you can find them like this −

You will see subdirectories including (but not limited to) the following −

  • actionpack-x.y.z

  • activerecord-x.y.z

  • rails-x.y.z

Over a windows installation, you can find them like this

You will see subdirectories including (but not limited to) the following −

MVC

ActionView and ActionController are bundled together under ActionPack.ActiveRecord provides a range of programming techniques and shortcuts for manipulating data from an SQL database. ActionController and ActionView provides facilities for manipulating and displaying that data. Rails ties it all together.

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Ruby on Rails Topics