Ruby on Rails

Ruby on Rails, Rails short, formerly also often short RoR, is an originally by David Heinemeier Hansson Meier in the Ruby programming language written and open source Web Application Framework. It was introduced in July 2004 to the public for the first time.

Rails is characterized by the principles of "do not repeat yourself " (DRY) and " convention over configuration ": That is, instead of a variable configuration conventions for the names of objects are observed, from which their interaction results in automatically. These functions enable the rapid implementation of requirements.

  • 6.1 Model
  • 6.2 controller
  • 6.3 View

Concept

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

History

Version 1.0

Originally Rails was developed for a web application called Base Camp, but then extracted therefrom and introduced in July 2004 to the public for the first time. The version 1.0 was completed on 13 December 2005.

Version 1.1

Already on 28 March 2006 was followed by the version 1.1. Were mainly New

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

Version 1.2

On 19 January 2007, Version 1.2 was released. Highlights of Version 1.2 were mainly

  • REST,
  • Routing based on MIME type and
  • An interface for the safe treatment of UTF- 8 strings.

In addition, a handful of methods have been marked as deprecated. This subsequently gave warnings and it was announced that she made ​​the next major release - will be removed from Rails - version 2.0.

Version 2.0

On 7 December 2007 appeared after almost a year of development work Rails 2.0. She brought several hundred new features and completed the changeover from SOAP to REST as a platform for Web services.

Version 2.1

On 1 June 2008, version 2.1, which brought a number of improvements and new features appeared:

  • Optimized treatment time zones
  • Allows you to define the application of dependencies on RubyGems and can track changes to models, whereby the database access more efficiently.
  • Named scopes introduced, with which queries can be defined with the most commonly used conditions.
  • Migration have been changed, that they are no longer numbered, but with a time stamp. The former handling resulted in developing in teams to problems when two developers created a new migration, which then received the same number.

Version 2.2

Version 2.2 was released on 21 November 2008 brought, among other things. :

  • Internationalization: Integrating the l18n - Gems is now a standard API for internationalization available.
  • Rails is from this version compatible with Ruby 1.9 and JRuby
  • Supports etag and last-modified in HTTP headers. Pages that need have not changed since the last visit so not be sent again.
  • Thread Safety

Version 2.3

The version 2.3 was released on March 15, 2009. It included, among many smaller improvements so-called templates. This used to be always generate required configurations directly with the preparation of the application. With the engines has made it possible to embed applications such as plug-ins in other Rails applications. Nested forms now allow comfortable, mapping defined dependencies between models in the view. Rails is based on this version of the middleware rack and therefore also allows access directly to them. With Rails Metal, it became possible application parts that are called very often and only provide simple functionality to greatly accelerate. However, the developer waives the most comfort, would provide the Rails else.

Version 3.0

29 August 2010 Rails 3.0 was released. Rails has been merged into this version with the second large Ruby web framework Merb. In addition, Rails was designed more modular. This should make it easier on the one hand, to use parts of Rails ( ActiveRecord example ) outside of Rails. Now also it is easier to be possible to replace some parts of desired rails by other libraries. Furthermore, it was converted Javascript support on 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 the are assembled and compressed before delivery in one file for all the CSS and Javascript files. This should improve the speed. On the front -end side come since 3.1 Sass for creating stylesheets and CoffeeScript as a JavaScript preprocessor to use. The Standard Library for JavaScript is not since Prototype but jQuery.

Version 3.2

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

Version 4.0

On June 25, 2013 version 4.0 was released.

Philosophy

The basic principles of Rails are " Do not repeat yourself " ( repeat do not ) and " Convention over configuration" ( convention over configuration ).

Scaffolding

Using the built- Scaffolding ( German as: scaffolding), it is possible Web applications on the fly to develop. If in the database as a field is added, it will appear immediately in the appropriate View / New / Edit view. The possibility of immediate visualizing a database field and linking of various database operations with just this text box is often referred to by the term CRUD ( Create, Read, Update, Delete ) or the CRUD framework. Scaffolding is intended primarily for prototyping and is almost always complemented in live applications with native code.

Web Server Support

To develop and test the to the Ruby Package, the web server WEBrick offers as an application server. For productive use, such as Apache or Lighttpd with FastCGI can be used, but any other server works with CGI or FastCGI support. Another possibility is the mostly written in Ruby web server Mongrel is suitable as opposed to WEBrick for productive use. From the Apache module mod_ruby is generally discouraged, instead of Phusion Passenger ( mod_rails referred to as ) is recommended. This is not only very fast and low maintenance, it is here, in contrast to all other mentioned servers also do not need to restart the web server when an application is deployed again. This is especially important in a shared hosting space.

Layer

Model

The back-end of a Rails application is usually a relational database. Access to these is made with the help of Active Record. This is an ORM layer that maps a class to a table and an attribute to a column. A data set in such a table corresponds to exactly one instance. Currently, a number of known databases such as SQLite, DB2, Informix, MySQL, Oracle, PostgreSQL, Microsoft SQL Server and Sybase are supported.

It is also possible to use a different format to dispense (e.g., XML files ) or entirely on a back end. Thanks, introduced in Rails 3.0 plugin API, you can choose the ORM library free, so in addition to ActiveRecord, are also home to Sequel and Datamapper, which is now used already by many Merb applications.

Controller

The control layer of a Rails application is made by using the action controller class. This is part of the Action Pack library. A controller encapsulates a specific business logic and provides interfaces to interact with these controls. These interfaces are called Actions. A typical Rails Request ( eg URL: / / servername.net / controller / action ) contains the name of the controller to be addressed. This is equivalent to the class name. Furthermore, a specific action is called, it will be shown within the controller class as a method. However, there is the possibility of adapting such a Rails request according to their own needs using the built-in routing mechanism.

View

For the presentation layer, the Class Action View is responsible. This is also part of the Action Pack library. The following output formats are currently supported by Rails:

  • HTML
  • XML - eg for XHTML and Web Services
  • Binary data

In addition, the following template systems are offered:

  • ERB for (X ) HTML and Javascript
  • Builder for XML
  • Haml
  • CoffeeScript

It is also possible to manipulate the HTTP header itself and to send as other formats of the client.

Rack middleware

Merb, Sinatra, Ramaze and camping are as Rails and Ruby frameworks that use the middleware rack and thus can also be mixed. From Rails version 3 Rails and Merb are fused.

670378
de