Model-View-Controller in Ruby on Rails

January 4, 2006 at 8:05 pm 1 comment

Ruby on Rails uses a development framework called Model-View-Controller. I was not really aware of it until today, but basically it is a separation between several components of the application. Once again, Wikipedia is a great source for this kind of information – Model-View-Controller. In order to start working with Ruby on Rails, a grasp of concept is required.

As I understand it, Model takes care of the database connections, View is somewhat easy – is basically an HTML template with Ruby code in-line, and Controller stores events, that are mostly user-induced (so, for example user hitting a Submit button on the HTML form). It also looks like Controller and View are used to store most of the logic of the application, while Model in Ruby on Rails is mostly transparent, and SQL calls are based on specific rules defined by Rails.

I still cannot fully understand the reason for this separation, and will need to get my hands dirty coding, before I can see the benefits of this. One benefit that was mentioned was a modified version of a well-known separation of content from presentation (CMS, Blog templates, Skin engines). In the case of M-V-C framework, we are able to separate View from Controller and Model, making it less painful to introduce GUI changes, while leaving the core “engine” without changes. 


Entry filed under: Uncategorized.

Ruby on Rails: Choice of IDE Model-View-Controller in PHP

1 Comment Add your own

  • 1. Kalid  |  June 17, 2007 at 3:52 am

    Hi, one of the key benefits of MVC is separating your code into maintainable chunks.

    It’s the same reason we use functions to separate functionality, and use separate CSS and JS files for styles and javascript. If each part does one thing, and one thing well (data, logic, or presentation) it’s easier to understand, debug, and add to later.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Trackback this post  |  Subscribe to the comments via RSS Feed

Recent posts

Starting to learn Rails?


Get Kindle - the best e-book reader, that I personally use, and the only one that you can read on the beach - very useful: Kindle Wireless Reading Device (6" Display, Global Wireless, Latest Generation)

%d bloggers like this: