In 2004, the web design company 37signals (known today as Basecamp) published the project-man­age­ment ap­plic­a­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­mei­er Hansson. In the same year this base ar­chi­tec­ture was extracted and published as its own open source web ap­plic­a­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­lic­a­tion that the software would end up being one of the most popular solutions for creating new web ap­plic­a­tions.

What is Ruby on Rails?

Ruby on Rails has been con­stantly advanced by de­velopers 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­form­a­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­form­a­tion in the source code or in a separate con­fig­ur­a­tion file. The im­ple­men­ted module active record reads this in­form­a­tion directly from the database.

The second design paradigm that RoR adheres to is ‘Con­ven­tion over con­fig­ur­a­tion’. The RoR framework presents its users certain con­ven­tions when it comes to naming classes. De­velopers following these con­ven­tions are able to save a vast amount of time when it comes to con­fig­ur­a­tion. However, Ruby on Rails also allows al­tern­at­ive con­fig­ur­a­tions, meaning users are still able to enjoy a high level of flex­ib­il­ity when it comes to pro­gram­ming their web apps.

Ruby: the flexible and platform-in­de­pend­ent 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­clus­ively used in Japan, the script language has since es­tab­lished itself as a popular al­tern­at­ive 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­por­ated the best aspects of other languages into Ruby. As an in­ter­preted script language, code is executed by an in­ter­pret­er, which means that it has a small dis­ad­vant­age when compared with compiled scripts; at the same time, however, this aspect makes Ruby more dynamic and flexible. Ruby code is platform in­de­pend­ent due to the fact that there are specific in­ter­pret­ers for all the con­ven­tion­al operating systems. One basic char­ac­ter­ist­ic of Ruby is the fact that it has a metaparadigm ability, a feature that also char­ac­ter­ises 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­pec­ted behaviour. As an open source software re­gistered under the free BSD licence, Ruby is supported by a large and active community that has con­trib­uted to numerous current program libraries. Most of these libraries are subject to this licence and play an important role when it comes to de­vel­op­ing modern web ap­plic­a­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­trol­ler ar­chi­tec­ture (MVC)

Ruby-on-Rails running time en­vir­on­ments are closed systems. They contain the in­ter­pret­er, the necessary pro­gram­ming libraries as well as the re­spect­ive scripts. Every Rails project is subject to an auto­mat­ic­ally generated directory structure that separates scripts, con­fig­ur­a­tions, classes, content, etc. from one another. Thanks to the struc­tur­al approach, it’s easy to maintain this web ap­plic­a­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­plic­a­tions are connected to re­la­tion­al databases. In order to com­mu­nic­ate with the cor­res­pond­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­vidu­al at­trib­utes on their cor­res­pond­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 present­a­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­res­pond­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­trol­ler

The con­trol­ler 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­res­pond­ing models from the database that are re­spons­ible for visu­al­isa­tion. As the central control unit for the Rails ap­plic­a­tion, Con­trol­ler also manages the caching behaviour and sum­mar­ises the different requests of in­di­vidu­al clients into a session.

The standard com­pon­ents of RoR frame­works

As a framework for web ap­plic­a­tions, Ruby on Rails’s standard version offers all of the com­pon­ents de­velopers need to program a well-rounded ap­plic­a­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 re­com­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­trol­ler: 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­vidu­al entries and con­trol­lers. In terms of naming, there’s a con­ven­tion that requires all Views to be named after their cor­res­pond­ing con­trol­ler.
  • Active Record: this module involves a central module for ma­nip­u­lat­ing the database of your Rails ap­plic­a­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­vidu­al 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­pon­ents, 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­ur­a­tions.
  • Action Mailer: Action Mailer makes it possible to send and receive e-mails in your web ap­plic­a­tion and makes it easy to setup an e-mail re­gis­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­men­ted its own railtie in order to start the in­stall­a­tion process or carryout con­fig­ur­a­tions on the framework. Railties are fur­ther­more necessary in order to add cus­tom­ised modules to Ruby on Rails

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

  • Two de­velopers 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­sidered 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­pend­ent language proves to be anything but easy and can often prove quite time consuming. As an in­ter­preted 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­pret­er language also leads to the fact that the speed of the developed ap­plic­a­tions is slower than with com­par­able Java ap­plic­a­tions. In com­par­is­on to Java, PHP also has some ad­vant­ages when it comes to sim­pli­city. It’s not without reason that the language is con­sidered 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­plic­a­tions that were developed using older version can sometimes be quite difficult. Ruby on Rails contains an in­teg­rated framework that allows pro­gram­mers to test the func­tion­al­ity of their ap­plic­a­tions at any time. Thanks to this feature, mistakes can be caught and corrected early on. Web 2.0 tech­no­logy like AJAX can only be used with fewer lines. Both Ruby and the Rails framework community both feature large and growing com­munit­ies, both of which offer an im­press­ive array of ex­ten­sions. The in­nov­at­ive philo­sophy of Rails, i.e. striving to provide de­velopers with the simplest approach to coding, has been a source of in­spir­a­tion for many other new frame­works. Symfony, CakePHP and the Zend Framework are all examples of such ap­proaches.

For whom is the Ruby Framework best suited?

Ruby on Rails offers everything that de­velopers creating modern web ap­plic­a­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­sib­il­ity to use web tech­no­lo­gies, like AJAX. The clear prin­ciples of ‘Don’t repeat yourself’ and ‘Con­ven­tion over con­fig­ur­a­tion’ offer the basis for clean and concise code that’s easily written. Some con­fig­ur­a­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­per­i­enced pro­gram­mers who’ve pre­vi­ously 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­teg­rated test en­vir­on­ment, pro­gram­mers are able to check their ap­plic­a­tions for possible errors during the de­vel­op­ment phase. Ruby on Rails is also ready to tackle more com­plic­ated ap­plic­a­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 licence, 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­plic­a­tions still aren’t as fast as those of the com­pet­i­tion. The code is first executed when users access the re­spect­ive content, which is why pro­cessing the inbound inquiries takes a bit longer lo­gist­ic­ally speaking than with pre-compiled lines of code. Pro­gram­mers will have to forego using the Rails framework if they wish to organise their ap­plic­a­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­ular­ity of RoR and fully assess the framework’s chances of taking the reins from the market leaders PHP, Java, and Python, but its ad­vant­ages and in­creas­ing pop­ular­ity of the Ruby framework speaks for them­selves.

Go to Main Menu