Sergheeva Yu.V.

National Mining University, Ukraine

The features of development modern web-applications The Ruby on Rails framework

 

Modern web-applications can be characterized as complicated software systems development and maintenance of which is nontrivial task. Today web-application frameworks are used extensively in developing web-applications such as a corporate website, web portal or a web service. Web-application frameworks are the basis for creating custom solutions; they provide the possibility to reuse the components for solving common problems of web-applications. Nowadays such frameworks as Zend (PHP), Symfony (PHP), Struts (Java) and Ruby on Rails (Ruby) are used extensively by developers all around the world.

Ruby on Rails is quickly becoming one of the most popular modern programming language framework combinations. Rails' seamless integration into web servers and databases and its elegant framework make a good choice for every programmer wishing to develop the latest and greatest web applications.

Ruby on Rails [3], often shortened to Rails or RoR, is an open source web application framework for the Ruby programming language. Ruby is a dynamic, object-oriented programming language [2]. Ruby supports multiple programming paradigms, including functional, object-oriented, imperative and reflective. It also has a dynamic type system and automatic memory management.

Like many web frameworks Rails uses the Model-View-Controller (MVC) [5] architecture pattern to organize application programming. Model-View-Controller architecture is a programming pattern for separating data, business logic (which both manipulates the data and interprets commands from the user), and presentation (which displays the manipulated data). The Model View Controller principle divides the work of an application into three separate, but closely cooperative subsystems.

The Model maintains the relationship between object and database and handles validation, association, transactions, and more. This subsystem is implemented in ActiveRecord library which provides an interface binding between the tables in a relational database and the Ruby program code that manipulates database records.

The View is what the user see, in Rails terms that means the web pages that appear in the browser. A presentation of data in a particular format triggered by a controller's decision to present the data. They are script based on templating systems like PHP, ASP, JSP, which are very easy to integrate with AJAX technology. This subsystem is implemented in ActionView library. In Rails views are written in a markup language, and by default that is ERb (Embedded Ruby).

The Controller interacts with the Model and passes the required data into the View.  Updating, creating, and destroying of database records are initiated in the controller. In addition, controllers are responsible for selecting the appropriate view. This subsystem is implemented in ActionController, which is a data broker sitting between ActiveRecord and ActionView[1].

MVC architecture in Figure 1.

 

Figure 1: The Model-View-Controller Architecture [4]

 

Ruby on Rails is available for Linux, Windows, and MacOS X and can be installed on various web servers such as Apache, LightSpeed and Lighttpd. Support for FastCGI, SCGI, or Mongrel. Several database drivers exist for Ruby. Framework Ruby on Rails maintains DBMSs, as Oracle, MySQL, Firebird, PostgreSQL and Microsoft SQL Server. Overall, Ruby on Rails can be used with the popular operating systems, web servers, and DBMSs.

Ruby on Rails initially utilized lightweight SOAP for web services; this was later replaced by RESTful web services. 

Ruby on Rails 3.0 uses a technique called Unobtrusive JavaScript to separate the functionality (or logic) from the structure of the web page, and jQuery is fully supported as a replacement for Prototype. Since version 2.0, Ruby on Rails by default offers both HTML and XML as output formats. The latter is the facility for RESTful web services. By using a RESTful architecture with Rails many of the underlying implementation details do not need to be specified.

 Ruby on Rails is separated into various packages, namely ActiveRecord (an object-relational mapping system for database access), ActiveResource (provides web services), ActionPack, ActiveSupport, ActionMailer, ect.  Apart from standard packages, developers can make plugins to extend existing packages.

Ruby on Rails web applications in Figure 2.

 

Figure 2:  Ruby on Rails Web Applications

Architectural Diagram

 

There are two basic principles that govern the way that Ruby on Rails works: “Don’t Repeat Yourself” and “Convention over Configuration”. The first is often referred to as DRY, or Don’t Repeat Yourself. The idea is to keep the language as simplistic as possible, so the code remains simple as well. “Convention over Configuration” means that a developer only needs to specify unconventional aspects of the application. For example, the programmer can rely on defaults on the naming of the classes and tables.

The framework Ruby on Rails can be regarded as an independent platform with a full set of required modules, documentation, ready-made solutions and high-quality development environment. Rails can be recommended to create different web-applications of varying complexity.

 

References:

1.       Learning Ruby on Rails/ Rails Framework/ URL: http://www.tutorialspoint.com/ruby-on-rails/rails-framework.htm

2.       Ruby a Programmer’s Best Friend/ URL: http://www.ruby-lang.org

3.       Ruby on Rails/URL: http://rubyonrails.org

4.       Sam Ruby, Dave Thomas, David Heinemeier Hansson, “Agile Web Development with Rails”, Third Edition, The Pragmatic Bookshelf., 2008.

5.       The MVC Architecture/ URL: http://guides.rubyonrails.org/getting_started.html