In 2004, the web design company 37signals (known today as Basecamp) published the project-man­age­ment ap­pli­ca­tion basecamp. This program contained features like to-do lists, time tracking options as well as messaging systems. One portion of the software was a base ar­chi­tec­ture that was designed by one of the product’s pro­gram­mers, David Heine­meier Hansson. In the same year this base ar­chi­tec­ture was extracted and published as its own open source web ap­pli­ca­tion framework in 2005. The name of this well-known framework that was developed is Ruby: Ruby on Rails (RoR or just ‘Rails’ for short). Nobody could have guessed upon its pub­li­ca­tion that the software would end up being one of the most popular solutions for creating new web ap­pli­ca­tions.

What is Ruby on Rails?

Ruby on Rails has been con­stant­ly advanced by de­vel­op­ers since the framework made first made its ap­pear­ance under an MIT license. All of these de­vel­op­ments have remained true to one important principle on which the RoR was founded: ‘Don’t repeat yourself’ (DYR). Each bit of in­for­ma­tion in a project based on the rails framework should only be present just one time. Following this concept, it’s suf­fi­cient to only define a table’s cells within the database without recording this in­for­ma­tion in the source code or in a separate con­fig­u­ra­tion file. The im­ple­ment­ed module active record reads this in­for­ma­tion directly from the database.

The second design paradigm that RoR adheres to is ‘Con­ven­tion over con­fig­u­ra­tion’. The RoR framework presents its users certain con­ven­tions when it comes to naming classes. De­vel­op­ers following these con­ven­tions are able to save a vast amount of time when it comes to con­fig­u­ra­tion. However, Ruby on Rails also allows al­ter­na­tive con­fig­u­ra­tions, meaning users are still able to enjoy a high level of flex­i­bil­i­ty when it comes to pro­gram­ming their web apps.

Ruby: the flexible and platform-in­de­pen­dent language of the Rails framework

In the mid-nineties, the Japanese pro­gram­mer, Yukihiro Matsumoto, published the object-oriented language, Ruby. At first almost ex­clu­sive­ly used in Japan, the script language has since es­tab­lished itself as a popular al­ter­na­tive to the industry leaders PHP, Python, etc. And there’s a reason for the program’s success: during the de­vel­op­ment phases, Matsumoto made it his goal to ensure that pro­gram­ming always remains fun and that’s why he in­cor­po­rat­ed the best aspects of other languages into Ruby. As an in­ter­pret­ed script language, code is executed by an in­ter­preter, which means that it has a small dis­ad­van­tage when compared with compiled scripts; at the same time, however, this aspect makes Ruby more dynamic and flexible. Ruby code is platform in­de­pen­dent due to the fact that there are specific in­ter­preters for all the con­ven­tion­al operating systems. One basic char­ac­ter­is­tic of Ruby is the fact that it has a meta­para­digm ability, a feature that also char­ac­ter­izes C++. This means that pro­gram­mers don’t have to settle with one certain pro­gram­ming paradigm. Thanks to the ‘principle of least surprise’, use of the script language is intuitive and, in general, isn’t generally coupled with un­ex­pect­ed behavior. As an open source software reg­is­tered under the free BSD license, Ruby is supported by a large and active community that has con­tributed to numerous current program libraries. Most of these libraries are subject to this license and play an important role when it comes to de­vel­op­ing modern web ap­pli­ca­tions. In­stalling libraries can be done with the help of so-called RubyGems One of these Gems, to which the public Web APIs Google and Facebook both count, is the Rails framework.

Model-view-con­troller ar­chi­tec­ture (MVC)

Ruby-on-Rails running time en­vi­ron­ments are closed systems. They contain the in­ter­preter, the necessary pro­gram­ming libraries as well as the re­spec­tive scripts. Every Rails project is subject to an au­to­mat­i­cal­ly generated directory structure that separates scripts, con­fig­u­ra­tions, classes, content, etc. from one another. Thanks to the struc­tur­al approach, it’s easy to maintain this web ap­pli­ca­tion. Here, the term model-view-control ar­chi­tec­ture is used. This ar­chi­tec­ture’s layers is set up as follows:

Model

Generally rails ap­pli­ca­tions are connected to re­la­tion­al databases. In order to com­mu­ni­cate with the cor­re­spond­ing database man­age­ment system and produce and/or ma­nip­u­late entries, the Ruby framework needs models. These depict classes on database tables and in­di­vid­ual at­trib­ut­es on their cor­re­spond­ing columns. This model layer is based on the ORM framework (object-re­la­tion­al mapping), Active Record. Since Rails 3.0, users have also had access to other ORM libraries, like Sequel.

Views

The view layer, or pre­sen­ta­tion layer, is required in order to access data from the model layer and depict this. To this end, Ruby on Rails uses the class, Action View, which supports a wide range of different output formats. Rendered in HTML document form, Views present the cor­re­spond­ing data to re­quest­ing users. XML or JSON documents are used to make access to database entries available to other programs or services.

Con­troller

The con­troller con­sti­tutes the interface between the Model and the view layer. It processes arriving requests through the web browsers and calls up the cor­re­spond­ing models from the database that are re­spon­si­ble for vi­su­al­iza­tion. As the central control unit for the Rails ap­pli­ca­tion, Con­troller also manages the caching behavior and sum­ma­rizes the different requests of in­di­vid­ual clients into a session.

The standard com­po­nents of RoR frame­works

As a framework for web ap­pli­ca­tions, Ruby on Rails’s standard version offers all of the com­po­nents de­vel­op­ers need to program a well-rounded ap­pli­ca­tion. The only ad­di­tion­al re­quire­ments are to install Ruby, an SQL database, and the packet manager, RubyGmes. For the SQL database re­quire­ment, the Rails team rec­om­mends the C-based open source pro­gram­ming library, SQLite, which contains a re­la­tion­al database system. Here are the standard modules of Ruby on Rails framework.

  • Action Con­troller: this module allows you to create the in­ter­faces between the database entries and programs and accessing users.
  • Action View: Action View makes it possible to generate Views for in­di­vid­ual entries and con­trollers. In terms of naming, there’s a con­ven­tion that requires all Views to be named after their cor­re­spond­ing con­troller.
  • Active Record: this module involves a central module for ma­nip­u­lat­ing the database of your Rails ap­pli­ca­tion. Users wishing to adhere to con­ven­tions regarding naming and type will have to do a little bit of con­fig­ur­ing in order to generate in­di­vid­ual models with this module. The optimal tool to this end, Ruby on Rails offers the powerful scaf­fold­ing system in order generate in­ter­faces for the four CRUD com­po­nents, which present datasets on object-oriented levels.
  • Active Resources: this module im­ple­ments the object-re­la­tion­al mapping for REST web services. Like Active Record, this component also aims to cut down on con­fig­u­ra­tions.
  • Action Mailer: Action Mailer makes it possible to send and receive e-mails in your web ap­pli­ca­tion and makes it easy to setup an e-mail reg­is­tra­tion.
  • Active Support: The module active support contains different useful auxiliary programs classes and standard library ex­ten­sions.
  • Railties: this component helps the various RoR frame­works work together. To this end, each module has im­ple­ment­ed its own railtie in order to start the in­stal­la­tion process or carryout con­fig­u­ra­tions on the framework. Railties are fur­ther­more necessary in order to add cus­tomized modules to Ruby on Rails.


The following joke trans­lat­ed from the German wikibooks.org entry on RoR high­lights an important point about the framework:

  • Two de­vel­op­ers are having a con­ver­sa­tion about pro­gram­ming languages. The first pro­gram­mer: ‘I work with Java and give PHP to my kids to play with’. To this the second pro­gram­mer answers: ‘I play with my kids and let Ruby do the work for me!’

While of course an ex­ag­ger­a­tion, there’s a certain element of truth to the joke. Java is con­sid­ered an excellent choice for complex solutions and is therefore often used for frame­works in different pro­fes­sion­al settings. But pro­gram­ming with this platform-in­de­pen­dent language proves to be anything but easy and can often prove quite time consuming. As an in­ter­pret­ed script language, Ruby also isn’t bound to any certain platform. At the same time coding with Ruby is much faster and it’s easy to adjust the code, which is much less extensive in the first place. The in­ter­preter language also leads to the fact that the speed of the developed ap­pli­ca­tions is slower than with com­pa­ra­ble Java ap­pli­ca­tions. In com­par­i­son to Java, PHP also has some ad­van­tages when it comes to sim­plic­i­ty. It’s not without reason that the language is con­sid­ered the standard solution when it comes to web de­vel­op­ment; it’s also the basis of different content man­age­ment systems, like WordPress, TYPO3, or Joomla. Due to the fact that PHP was set up more or less in an arbitrary manner and hasn’t always been object oriented, designing upgrades for web ap­pli­ca­tions that were developed using older version can sometimes be quite difficult. Ruby on Rails contains an in­te­grat­ed framework that allows pro­gram­mers to test the func­tion­al­i­ty of their ap­pli­ca­tions at any time. Thanks to this feature, mistakes can be caught and corrected early on. Web 2.0 tech­nol­o­gy like AJAX can only be used with fewer lines. Both Ruby and the Rails framework community both feature large and growing com­mu­ni­ties, both of which offer an im­pres­sive array of ex­ten­sions. The in­no­v­a­tive phi­los­o­phy of Rails, i.e. striving to provide de­vel­op­ers with the simplest approach to coding, has been a source of in­spi­ra­tion for many other new frame­works. Symfony, CakePHP and the Zend Framework are all examples of such ap­proach­es.

For whom is the Ruby Framework best suited?

Ruby on Rails offers every­thing that de­vel­op­ers creating modern web ap­pli­ca­tions need: excellent struc­tures for creating in­ter­faces, the ability to easily set up con­nec­tions to SQL databases as well as the pos­si­bil­i­ty to use web tech­nolo­gies, like AJAX. The clear prin­ci­ples of ‘Don’t repeat yourself’ and ‘Con­ven­tion over con­fig­u­ra­tion’ offer the basis for clean and concise code that’s easily written. Some con­fig­u­ra­tions can be achieved without any problems, as Ruby provides pro­gram­mers with all the liberties they may need. This makes the framework suitable for both beginners as well as ex­pe­ri­enced pro­gram­mers who’ve pre­vi­ous­ly only worked with script languages.  Thanks to the scaf­fold­ing system, pro­to­types of planned web projects can be quickly drafted. And due to the in­te­grat­ed test en­vi­ron­ment, pro­gram­mers are able to check their ap­pli­ca­tions for possible errors during the de­vel­op­ment phase. Ruby on Rails is also ready to tackle more com­pli­cat­ed ap­pli­ca­tions. With the help the ex­ten­sions, RubyGems, pro­gram­mers are able to add the required in­ter­faces, libraries, or optical features to their projects. Given that Ruby and the RoR framework are subject to the free BSD license, using some of these ex­ten­sions may entail new costs when it comes to hosting your web project. Despite its user-friend­li­ness, it’d be a mistake to assume that you don’t need any pro­gram­ming skills to get started with the framework. In contrast to the joke above, Ruby isn’t able to relieve pro­gram­mers of all the work involved. Regarding operation speed, RoR ap­pli­ca­tions still aren’t as fast as those of the com­pe­ti­tion. The code is first executed when users access the re­spec­tive content, which is why pro­cess­ing the inbound inquiries takes a bit longer lo­gis­ti­cal­ly speaking than with pre-compiled lines of code. Pro­gram­mers will have to forego using the Rails framework if they wish to organize their ap­pli­ca­tion with content man­age­ment systems like Durpal, Joomla, or WordPress. Like many other platforms, these are all based on PHP. There are, however, many CMS solutions based on Ruby on rails, like Alchemy CMS. It’s difficult to assess the pop­u­lar­i­ty of RoR and fully assess the framework’s chances of taking the reins from the market leaders PHP, Java, and Python, but its ad­van­tages and in­creas­ing pop­u­lar­i­ty of the Ruby framework speaks for them­selves.

Go to Main Menu