Site banner
 
Menu arrow Home                    
 
 

0504
.
Ruby on Rails
Nill

Ruby on Rails - Rails' MVC architecture - Encyclopedia II

Nill
The pieces of the Model-View-Controller (MVC) architecture in Ruby on Rails are as follows: Ruby on Rails - Model. In object-oriented, database-driven MVC web applications, Model consists of the classes representing RDBMS tables. In Ruby On Rails, Model classes are handled through the Active Record. Usually, all the programmer needs to do is to subclass the ActiveRecord::Base class, and the program will automatically figure out which RDBMS table to use and what columns the table has. Relationships between tables are specified with simple com ...
Nill
Ruby on Rails, Ruby on Rails - Ajax on Rails, Ruby on Rails - Controller, Ruby on Rails - Database support, Ruby on Rails - History, Ruby on Rails - Model, Ruby on Rails - Other modules, Ruby on Rails - Philosophy, Ruby on Rails - Projects Using Ruby on Rails, Ruby on Rails - Rails' MVC architecture, Ruby on Rails - Requirements, Ruby on Rails - View, Ruby on Rails - Web server support
Nill
Nill
Nill

The pieces of the Model-View-Controller (MVC) architecture in Ruby on Rails are as follows:

Ruby on Rails - Model

In object-oriented, database-driven MVC web applications, Model consists of the classes representing RDBMS tables.

In Ruby On Rails, Model classes are handled through the Active Record. Usually, all the programmer needs to do is to subclass the ActiveRecord::Base class, and the program will automatically figure out which RDBMS table to use and what columns the table has. Relationships between tables are specified with simple commands.

Ruby on Rails - View

In MVC, View is the display logic, or how the data from the Controller classes is displayed. In web applications, this frequently consists of a minimal amount of code, interspersed in HTML.

There are currently many ways the views can be handled – the underlying view code is part of the Action Pack. The method in Rails itself is to use Embedded Ruby (.rhtml files), which are basically fragments of HTML with some Ruby code interspersed, with syntax quite similar to JSP. HTML and XML can also be constructed programmatically with Builder or through Liquid template system.

For each method in the controller that needs to display user output, a small HTML code fragment needs to be written. The page layout is described separately from the controller action that displays layouts, and the fragments can also call other fragments.

Ruby on Rails - Controller

In MVC, Controller classes respond to user interaction and call the application logic, which in turn manipulates the data in Model and displays the data through View. In web-based MVC applications, the Controller methods are initiated by the user through the web browser.

Controller implementation is handled through Rails' Action Pack, which has class ApplicationController. Rails applications simply subclass ApplicationController and write required actions as methods, which can then be accessed through the web, typically in form of /example/method, which calls ExampleController#method, and presents the data using the view file /app/views/example/method.rhtml, unless the method redirects elsewhere.

Rails also provides out-of-the-box scaffolding, which can quickly construct most of the logic and views needed to do common operations, such as CRUD.




Wikipedia

Adapted from the Wikipedia article "Rails' MVC architecture", under the G.N U Free Docmentation License. Please also see http://en.wikipedia.org/wiki/Main_Page

Nill
More material related to Ruby On Rails can be found here:
Nill
Main Page
for
Ruby On Rails



Videos - Ruby on Rails
Web Development with Ruby On RailsWeb Development with Ruby On Rails

The Ruby on Rails framework gives you the tools you need to develop web applications faster. In this webinar, you'll learn about...

Ruby on Rails - Part 4: Advanced Active RecordRuby on Rails - Part 4: Advanced Active Record

Ruby on Rails Intensive 1-Day Course Part 4: Advanced Active Record Multi-table associations, embedding data structures, single-...

Ruby on Rails, Vim, and rails.vimRuby on Rails, Vim, and rails.vim

Demonstration of the Vim plugin for Ruby on Rails: rails.vim

Ruby on Rails - Part 5: AJAX and TestingRuby on Rails - Part 5: AJAX and Testing

Ruby on Rails Intensive 1-Day Course Part 5: AJAX and Testing Deployment and Lifecycle Management: Automating deployment, schema...




.nill


  » Home » » Home »  


P