Ruby on Rails
Ruby on Rails
|
|
---|---|
Rails standard page |
|
Basic data
|
|
developer | Rails core team |
Publishing year | December 13, 2005 |
Current version |
6.0.3.1 ( June 16, 2020 ) |
operating system | cross-platform |
programming language | Ruby |
category | Web framework |
License | MIT license |
rubyonrails.org |
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.
concept
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 Script.aculo.us and offers methods to easily develop Ajax -applications.
history
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
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
etag
andlast-modified
in 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.
philosophy
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
,ID
meaning that a model with the name is storedCustomer
in the file#{Rails.root}/app/models/customer.rb
and the associated tablecustomers
is called. If this model is linked to a model via a 1: N relationshipContract
, it is expected thatcontracts
a foreign key with the name iscustomer_id
present 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.
Scaffolding
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 .
layers
Model
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.
Controller
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 :) //servername.net/controller/action
contains 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.
View
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:
- HTML
- XML - e.g. B. for XHTML and Web Services
- JavaScript - RJS templates
- Binary data
The following template systems are also offered:
- ERB for (X) HTML and JavaScript
- XML builder
- Haml
- Sass
- CoffeeScript
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.
literature
- Sam Ruby, David Thomas , David Heinemeier Hansson : Agile Web Development with Rails 4 ,
O'Reilly, 4th edition 2013, ISBN 1-9377-8556-4
(German translation of the 1st edition: Agile Web Development with Rails , 2006. ISBN 3-446-40486-4 ) - Stefan Wintermeyer: Ruby on Rails 3.2 , Addison-Wesley, 1st edition 2012, ISBN 978-3-82732-989-9 ( online version )
- Hussein Morsy, Tanja Otto: Ruby on Rails 3.1 , Galileo Computing, 2nd edition 2011, ISBN 978-3-8362-1490-2
- Stefan Tennigkeit, Michael Voigt: Ruby on Rails 3: With DataMapper, I18N & L10N and full text search with Sphinx ,entwickler.press, 1st edition 2010, ISBN 978-3-86802-026-7
- Ralf Wirdemann, Thomas Baustert: Rapid Web Development with Ruby on Rails ,
Hanser, 3rd edition 2008, ISBN 3-4464-1498-3 - Denny Carl: Practical Knowledge Ruby on Rails , 2007, O'Reilly OpenBook
- Rob Orsini: Rails Cookbook , 2007, O'Reilly OpenBook
Web links
- Official website (English)
- German Ruby-on-Rails site with book list and tutorials
- Rails for Zombies interactive tutorial in the browser
- Railscasts, tutorial screencasts to Ruby on Rails (English)
- Tutorial, instructions "from scratch" (English)
Individual evidence
- ↑ rubyonrails.org/core ( Memento of the original from December 5, 2012 in the web archive archive.today ) 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
- ↑ v6.3.0.1 . May 18, 2020 (accessed May 24, 2020).
- ↑ 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).
- ↑ 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).
- ↑ Rails 2.0: It's done! Retrieved October 6, 2012 .
- ↑ Jo Bager: Ruby on Rails 2.0 web application environment is ready. Retrieved October 6, 2012 .
- ↑ 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).
- ↑ Riding Rails: Rails 3.0: It's ready. Retrieved April 12, 2012 .
- ↑ Rails Weblog: Merb gets merged into Rails 3! Retrieved October 6, 2012 .
- ↑ Riding Rails: Rails 3.1.0 has been released! August 31, 2011, accessed April 12, 2012 .
- ↑ Morsy and Otto 2012: Ruby on Rails 3.1, p. 28
- ↑ Riding Rails: Rails 3.2.0: Faster dev mode & routing, explain queries, tagged logger, store. January 20, 2012, accessed April 12, 2012 .
- ↑ Release Notes: Riding Rails: Rails 4.0: Final version released! June 25, 2013, accessed July 25, 2013 .
- ↑ Release Notes: Rails 4.1.0: Spring, Variants, Enums, Mailer previews, secrets.yml. April 8, 2014, accessed August 5, 2014 .
- ↑ Release Notes: Rails 4.2: Active Job, Asynchronous Mails, Adequate Record, Web Console, Foreign Keys. December 19, 2014, accessed December 21, 2014 .
- ↑ Release Notes: Ruby on Rails 5.0 Release Notes. Retrieved July 19, 2016 .
- ↑ Release Notes: Ruby on Rails 5.1 Release Notes. Retrieved January 31, 2018 .
- ↑ Release Notes: Rails 5.2.0 FINAL. April 9, 2018, accessed August 3, 2018 .
- ↑ Release Notes: Rails 6.0 Final Release. August 15, 2019, accessed on March 21, 2020 .