Migrate a Ruby on Rails App to Rails 4.x with “Strong Parameters”

A helpful rake task I’m just updating a three year old rails app from 3.2 to 4.2. One of the changes is that now the controller is responsible to protect against mass assignments. I think this is the right architecture, as the controller has the job to receive the input parameters and transfer them to …

(Deutsch) Ruby On Rails Datenbankoptimierung Teil 2

[Zu Teil 1] Verknüpfungen mit dem SQL-join Relationale Datenbanken erlauben es, Tabellen miteinander zu verknüpfen. In SQL gibt es für diese Verknüpfung das Schlüsselwort “JOIN“. Eine solche Verknüpfung kann theoretisch sehr frei spezifiziert werden, in der Praxis wird man fast immer aufgrund der Gleichheit bestimmter ID-Spalten verknüpfen. In unserem Beispiel eines Schiffsinformationssystems haben wir eine …

Optimize the Ruby-on-Rails database – part one

Reduce the number of database queries A typical web application does many database queries before it delivers the response page to the web browser. The application needs to wait for the response of each of these database queries. It gets an additional slow down because of process switching. The database server must analyze each request, …

Rails ActiveRecord: count, length or size?

The object oriented database layer “ActiveRecord” offeres three different methods to determine the number of objects: count(), length() und size(). Alle drei Methoden liefern das gleiche Ergebnis. Was nehmen wir wann? Warum ist es überhaupt wichtig? Nimmt man die falsche Methode, dann erzeugt unsere Ruby-on-Rails-Anwendung überflüssige Datenbankabfragen oder braucht mehr Speicher als eigentlich nötig. Die …

Multilingual Websites with Ruby on Rails (3)

Part 3 – Quality Assurence Texte gehören zu den Teilen einer Anwendung, die häufig geändert werden. Wenn dann noch externe Übersetzer im Spiel sind, kann es leicht zu fehlenden Übersetzungen kommen Wir möchten deshalb automatisch testen, dass es zu allen Texten in Sprache A auch Übersetzungen in Sprache B vorhanden sind. Ein solcher Test allein …

Multilingual Websites with Ruby on Rails (2)

Part 2 – Variables, Validations, Model Classes Web pages often contains sentences in which a single word is changing. For example, “You are logged in as xxxx.” For the translation, we can obviously assemble the sentence from the components. There is often a problem, because the order of the words is different in different languages …