Javatpoint Logo
Javatpoint Logo

Ruby on Rails MVC

Like most of the other frameworks, Rails is also based on MVC pattern. It basically works as following:

Requests first come to the controller, controller finds an appropriate view and interacts with model which in turn interacts with database and send response to controller. Then controller gives the output to the view based on the response.


Model

The models are classes in Rails. They interact with database, store data, handles validation, transaction, etc.

This subsystem is implemented in ActiveRecord library. This library provides an interface between database tables and Ruby program code that manipulates database records.

Ruby method names are automatically generated from database tables field names.


View

View represent data in a particular format in an application for the users. It handles HTML, CSS, JavaScript and XML in an application. They do what controller tells them.

This subsystem is implemented in ActionView library. This library is an Embedded Ruby (Erb) based system which define presentation templates for data presentation.


Controller

Controller directs traffic to views and models. It query models for data from the database and display the desired result with the help of view in an application.

This subsystem is implemented in ActionController library. This library is a data broker sitting between ActiveRecord and ActionView.

Ruby On rails mvc 1
Next TopicRuby on rails rvm




Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA