Ruby-on-Rails
  Home arrow Ruby-on-Rails arrow Page 2 - Getting Started with Ruby on Rails
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
RUBY-ON-RAILS

Getting Started with Ruby on Rails
By: A.P.Rajshekhar
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 14
    2006-08-01

    Table of Contents:
  • Getting Started with Ruby on Rails
  • Understanding the Terminology of Ruby-on-Rails
  • A Ruby-on-Rails Application, Step by Step
  • Rails in the Real World

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Getting Started with Ruby on Rails - Understanding the Terminology of Ruby-on-Rails


    (Page 2 of 4 )

    RoR is based on Ruby and it follows the MVC pattern. Now what is this MVC pattern and what are its types? MVC is short for Model View Controller where the components (obviously) are Model, View, and Controller. MVC comes in two flavors, MVC-Model I and MVC-Model II. Before going into the types of MVC and the type followed by RoR, let's look at each of the components of MVC individually.

    Model

    The definition states that Model is “The domain specific representation of information on which the application operates.” Essentially, the Model is responsible for maintaining the state of the application. And state refers to the data contained within the instance of an application at a given instance.

    In short, Model deals with the data of the application. However, in the absence of the context of usage, data is raw and useless. So Model contains the logic that transforms the data by enforcing the business rules that apply to the data. For example, if the application deals with customer orders, the Model would contain (obviously) the data related to the orders. Along with that, the Model would also contain the logics that govern the discounts and so forth.

    View

    The main function of the View component is to render the Model into a suitable form for user interaction, generally a GUI element such as textbox, combo box, and so on. To elaborate, the data within the Model has to be represented in a form that humans can read. This representation of data into a human readable form is done by View.

    View uses various GUI controls to present the data to the user. Many times, the Model contains sets of data, out of which only the relevant ones have to be shown to the user. To achieve this, the View includes logic to retrieve the required data from a collection of data present in the Model. The logic present in the View is also known as Presentation Logic. If I use the previous example, if the Model contains data about different orders from the same customer and if all of the data from the orders must be displayed a single order at a time, then that logic would be in the View.

    Controller

    According to its definition, the Controller “Responds to an event, typically a user action and invokes changes on the model and perhaps the view." That means controllers receive an event from the user (input), interact with the Model by either retrieving new data based on user input or updating the Model based on the data from the input, and display the appropriate view to the user. In a nutshell, the Controller defines the flow of application logic and thus orchestrates the application. Relying on the earlier example, when a customer updates an order, it is the controller that, in reality, updates the Model and shows the view according to the updated data.

    Pictorially, the interaction between the Model, View and Controller would be:

     

    On the basis of how the Controller is implemented, there are two types or models (not to be confused with the Model of MVC; here model means type) of MVC architecture.

    The MVC-Model I is also known as the Page Centric MVC. In this type of MVC model, the Controller is embedded along with the View (or Page). The Model is separate. That means if a templating technology (like RHTML, JSP) is used, the logic of the Controller would be embedded with the template created using the templating technology.

    In MVC-Model II, the Controller is separated from the View. If the components of MVC are taken as layers, then, in model II, all the layers are separate. The logic for the Controller is no longer embedded within a template (such as RHTML. JSP).

    RoR follows MVC-Model II, which implies that the View and Controller are placed separately. View is placed in RHTML and Controller logic is embedded in ruby files. Hence Ruby-on-Rails based applications have to follow the MVC-Model II pattern. The steps required to create such an application are the focus of the next section.

    More Ruby-on-Rails Articles
    More By A.P.Rajshekhar


       · RoR is the latest in the field of server-side frameworks. When compared to other...
     

    RUBY-ON-RAILS ARTICLES

    - Iterating and Incrementing Strings in Ruby
    - Comparing and Manipulating Strings in Ruby
    - Strings in Ruby
    - Ruby On Rails: Making Your First Dynamic Site
    - Ruby on Rails: Beginning Rails
    - Ruby: Modules, Mixins, Fixins, and Rails
    - Controlling Information Access with the Rail...
    - URLs, Filters and the Rails Action Controller
    - Flash and the Rails Action Controller
    - Rails Action Controller
    - Dropping and Sorting with AJAX and script.ac...
    - Drag and Drop with script.aculo.us and Rails
    - Introducing script.aculo.us
    - Ruby Classes and Objects
    - Ruby Loops






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
    Stay green...Green IT