Ruby on Rails

from Wikipedia, the free encyclopedia
Ruby on Rails

Ruby on Rails logo.jpg
Rails default index.png
Rails standard page
Basic data

developer Rails core team
Publishing year December 13, 2005
Current  version
( June 16, 2020 )
operating system cross-platform
programming language Ruby
category Web framework
License MIT license

Ruby on Rails , shortly Rails , formerly also often short RoR , is an original by David Heine Meier Hansson in the programming language Ruby written and open source web framework . It was presented to the public for the first time in July 2004.

Rails is characterized by the principles of “ don't repeat yourself ” (DRY) and “ convention before configuration ”: This means that instead of a variable configuration , conventions for naming objects must be adhered to, from which their interaction automatically results. These functions enable requirements to be implemented quickly.


Rails follows the " Model View Controller " architecture (MVC) and consists of five modules:

Active support
Ruby extensions from Rails
Active Record
Object abstraction layer based on the object-relational pattern or model (ORM) (the "M" from MVC) by Martin Fowler
Action pack
Request handling and response output. The requests are handled by a public method of the controller (Action Controller, the "C" from MVC). The output is carried out using a template (Action View, the "V" from MVC).
Action mailer
Sending and receiving emails
Active Resource
With version 2.0, Action Webservice has been replaced by Active Resource: Web service programming, support for XML-RPC and REST .

Rails integrates the JavaScript - frameworks Prototype and and offers methods to easily develop Ajax -applications.


Version 1.0

Rails was originally developed for the web-based project management software Basecamp , but was then extracted from it and presented to the public for the first time in July 2004. Version 1.0 was completed on December 13, 2005.

Version 1.1

Version 1.1 followed on March 28, 2006. Most of all they were new

  • RJS ( Ruby on Rails JavaScript Templates ), which made it possible to create templates for JavaScript, as well as
  • Improvements to ActiveRecord, which among other things allow the use of polymorphic associations.
  • In addition, the performance has been improved.

Version 1.2

Version 1.2 was released on January 19, 2007. The highlights of version 1.2 were above all

  • REST ,
  • Routing according to MIME type and
  • an interface for the safe handling of UTF-8 strings.

In addition, a handful of methods have been marked as deprecated . These then issued warnings and it was announced that they would be removed from Rails in the next major release - version 2.0.

Version 2.0

On December 7th, 2007, Rails 2.0 was released after almost a year of development work. It brought several hundred innovations with it and made the switch from SOAP to REST as a platform for web services .

Version 2.1

Version 2.1 was released on June 1st, 2008, which brought some improvements and innovations:

  • Treatment of time zones optimized
  • Allows you to define the application of dependencies on RubyGems and track changes to models, which also makes database access more efficient.
  • Named scopes introduced with which queries with frequently required conditions can be defined.
  • Migrations have been changed so that they are no longer numbered, but are given a time stamp . The previous handling led to problems when developing in teams if two developers created a new migration at the same time, which was then given the same number.

Version 2.2

Version 2.2 was released on November 21, 2008. Among other things, it brought the following:

  • Internationalization: By integrating the l18n- Gems , a standard API is now available for internationalization.
  • Rails is compatible with Ruby 1.9 and JRuby as of this version
  • Supported etagand last-modifiedin HTTP headers. Pages that have not changed since the last visit do not have to be sent again.
  • Thread safety

Version 2.3

Version 2.3 was released on March 15, 2009. In addition to many smaller improvements, it included so-called templates . These are used to generate configurations that are required repeatedly when the application is created. The engines made it possible to embed applications such as plugins in other Rails applications. Nested forms now make it easy to map defined dependencies between models in the view. From this version, Rails is based on the Middleware Rack and therefore allows direct access to it. With Rails Metal it became possible to accelerate application parts that are called very frequently and only provide simple functionality. However, the developer foregoing most of the convenience that Rails would otherwise offer.

Version 3.0

Rails 3.0 was released on August 29, 2010. In this version, Rails was merged with the second large Ruby web framework Merb . Rails was also designed to be more modular. On the one hand, this should make it easier to use parts of rails (e.g. ActiveRecord) outside of rails. At the same time, it is now easier to replace certain parts of Rails with other libraries if desired . Furthermore, the Javascript support was switched to Unobtrusive JavaScript .

Version 3.1

A first update of Rails 3 was released on August 31, 2011. In this version, the asset pipeline was introduced, with which all CSS and Javascript files are combined and compressed into one file each before delivery. This is supposed to improve the speed. On the front-end side, Sass has been used as a JavaScript preprocessor for the development of stylesheets and CoffeeScript since 3.1 . The standard library for JavaScript is no longer Prototype , but jQuery .

Version 3.2

Version 3.2 was released on January 20, 2012. Among other things, the performance of the development mode has been improved.

Version 4.0

Version 4.0 was released on June 25, 2013.

Version 4.1

Version 4.1.0 was released on April 8, 2014.

Version 4.2

Version 4.2.0 was released on December 19, 2014.

Version 5.0

Version 5.0 was released on June 30, 2016. The main innovations are the integration of Action Cable , a WebSocket implementation in Ruby, generators for lean web APIs and a dedicated test framework called Test Runner .

Version 5.1

Version 5.1 was released on April 27, 2017. The main new features are support for Yarn , a package manager for Javascript dependencies, and Webpack , an asset bundler for JavaScript. Furthermore, the methods for generating web forms ( form_for , form_tag ) have been standardized (to form_with ), tests using web browsers ( Capybara ) have been integrated and JQuery has been removed as a mandatory dependency.

Version 5.2

Version 5.2.0 was released on April 9, 2018.

Version 6.0

Version 6.0.0 was released on August 15, 2019. New in this version are Webpack as standard for JavaScript, Action Mailbox, Action Text, parallel testing, support of multiple databases and a new autoloader.


As fundamental principles of Rails are "Do not repeat yourself" ( Repeat you not ) and "Convention over configuration" ( convention over configuration ).

"Don't repeat yourself"
Each piece of information should only be available once. In Rails, for example, thanks to ActiveRecord, it is sufficient to define the columns of a table only in the database. Instead of requesting this information encoded a second time in the source code or a configuration file, ActiveRecord reads this information directly from the database. Rails automatically creates getter and setter methods for the model so that the data can be easily written to and read from the database. This method also has the advantage that the information cannot become inconsistent if, for example, the database has been changed but this has been forgotten for the configuration file.
"Convention over Configuration"
Rails expects reasonable default values. It is expected, for example, that the primary key of a table is of the type Integer, IDmeaning that a model with the name is stored Customerin the file #{Rails.root}/app/models/customer.rband the associated table customersis called. If this model is linked to a model via a 1: N relationship Contract, it is expected that contractsa foreign key with the name is customer_idpresent in the table . If these default values ​​do not apply, they can simply be reconfigured, but in most cases the developer is spared the extensive configuration options.


By means of the built-in scaffolding (German: scaffolding) it is possible to develop web applications on the fly . If, for example, a field is added to the database, it appears immediately in the corresponding View / New / Edit view. The possibility of immediate visualization of a database field and the linking of various database operations with this very text field is often referred to with the term CRUD ( C reate, R ead, U pdate, D elete) or CRUD framework. Scaffolding is primarily intended for prototyping and is almost always supplemented with your own code in productive applications.

Web server support

The WEBrick web server belonging to the Ruby package is ideal as an application server for development and testing . For productive use z. B. Apache or Lighttpd can be used with FastCGI , but any other web server with CGI or FastCGI support also works. Another possibility is the Mongrel web server, mostly written in Ruby, which, unlike WEBrick, is suitable for productive use. The Apache module mod ruby is generally not recommended; Phusion Passenger (also known as mod_rails) is recommended instead . This is not only particularly fast and low-maintenance, in contrast to all the other servers mentioned, it is also not necessary to restart the web server when an application is activated again. This is especially important with shared hosting .



The back end of a Rails application normally forms a relational database . Access to these is established with the help of ActiveRecord. This is an ORM layer that maps a class to a table and an attribute to a column. A data record in such a table corresponds to exactly one instance. A number of well-known databases such as SQLite , Db2 , Informix , MySQL , Oracle , PostgreSQL , MongoDB , Microsoft SQL Server and Sybase are currently supported.

It is also possible to use a different format (e.g. XML files) or to do without a backend entirely. Thanks to the plug-in API introduced in Rails 3.0, you can freely choose the ORM library so that, in addition to ActiveRecord, Sequel and Datamapper , which are already used by many Merb applications, are available.


The control layer of a Rails application is created using the ActionController class. This is part of the ActionPack library. A controller encapsulates a certain business logic and offers interfaces to interact with it in a controlled manner. These interfaces are called actions. A common Rails request (e.g. URL :) // the name of the controller to be addressed. This is equivalent to the class name. Furthermore, a special action is called; this is represented as a method within the controller class. However, the built-in routing mechanism allows you to adapt such a Rails request to your own needs.


The ActionView class is responsible for the presentation layer. This is also part of the ActionPack library. The following output formats are currently supported by Rails:

The following template systems are also offered:

It is also possible to manipulate the HTTP header yourself and thus send other formats to the client.

Middleware rack

Merb , Sinatra , Ramaze and Camping , like Rails, are also Ruby frameworks that use the middleware rack and can therefore also be mixed. From Rails version 3, Rails and Merb are merged.


Web links

Wikibooks: Website development: Ruby on Rails  - learning and teaching materials
Wikibooks: tutorial and reference work  - learning and teaching materials

Individual evidence

  1. ( Memento of the original from December 5, 2012 in the web archive ) Info: The archive link was automatically inserted and not yet checked. Please check the original and archive link according to the instructions and then remove this notice. - Ruby Core team @1@ 2Template: Webachiv / IABot /
  2. v6.3.0.1 . May 18, 2020 (accessed May 24, 2020).
  3. Riding Rails: Rails 1.1: RJS, Active Record ++, respond_to, integration tests, and 500 other things! Archived from the original on August 5, 2010 ; accessed on October 6, 2012 (English).
  4. Riding Rails: Rails 1.2: REST admiration, HTTP lovefest, and UTF-8 celebrations. Archived from the original on June 12, 2011 ; accessed on October 6, 2012 (English).
  5. Rails 2.0: It's done! Retrieved October 6, 2012 .
  6. Jo Bager: Ruby on Rails 2.0 web application environment is ready. Retrieved October 6, 2012 .
  7. Riding Rails: Rails 2.1: Time zones, dirty, caching, gem dependencies, caching, etc. Archived from the original on June 12, 2011 ; accessed on October 6, 2012 (English).
  8. Riding Rails: Rails 3.0: It's ready. Retrieved April 12, 2012 .
  9. Rails Weblog: Merb gets merged into Rails 3! Retrieved October 6, 2012 .
  10. Riding Rails: Rails 3.1.0 has been released! August 31, 2011, accessed April 12, 2012 .
  11. Morsy and Otto 2012: Ruby on Rails 3.1, p. 28
  12. Riding Rails: Rails 3.2.0: Faster dev mode & routing, explain queries, tagged logger, store. January 20, 2012, accessed April 12, 2012 .
  13. Release Notes: Riding Rails: Rails 4.0: Final version released! June 25, 2013, accessed July 25, 2013 .
  14. Release Notes: Rails 4.1.0: Spring, Variants, Enums, Mailer previews, secrets.yml. April 8, 2014, accessed August 5, 2014 .
  15. Release Notes: Rails 4.2: Active Job, Asynchronous Mails, Adequate Record, Web Console, Foreign Keys. December 19, 2014, accessed December 21, 2014 .
  16. Release Notes: Ruby on Rails 5.0 Release Notes. Retrieved July 19, 2016 .
  17. Release Notes: Ruby on Rails 5.1 Release Notes. Retrieved January 31, 2018 .
  18. Release Notes: Rails 5.2.0 FINAL. April 9, 2018, accessed August 3, 2018 .
  19. Release Notes: Rails 6.0 Final Release. August 15, 2019, accessed on March 21, 2020 .