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 the right model, or reject the request altogether. The browser of the user does not talk directly with the model, and the model does not know which user with which rights has done a request.

With the strong parameters, all allowed parameters need to be in a white list. My app has 60 controllers, so writing all the code for the strong parameters is a big task. For each controller you need to collect the right attributes and put them in the permit-call. Continue reading “Migrate a Ruby on Rails App to Rails 4.x with “Strong Parameters””

Quantum Computing with Ruby

Few know that you already can do quantum computing with the Japanese programming language Ruby.

If you have a Ruby interpreter installed on your computer, you can follow the following experiment, which is inspired by Erwin Schrödinger. (See also my article from 1997)

Continue reading “Quantum Computing with Ruby”

Huawei, Kelsterbach, Rüsselsheim und Raunheim

Notes about „smart city“

The Mayors of three German cities signed a cooperation with Huawei at the CeBIT Fair. I was an observer of the signing ceremony.

Majors signing the agreement. A big display show the text: Smart City Cooperation 3Wins - Huawei LOI Signing
Rüsselsheim Mayor Patrick Burghardt, Raunheims Mayor Thomas Jühe, and Kelsterbachs Mayor Manfred sign a cooperation agreement with Pablo Cui from Huawei.

The cities are located near the biggest German airport of Frankfurt in the economically active Rhein-Main region. However, the cities have combined less inhabitants than Huawei has employees.

What is the agreement about? The cities wish to receive Smart City services, and Huawei plans to open a Smart City Exhibition Center.

What are these smart services exactly? The speech of the mayors were quite generic. If you read the press release, you find only one specific project: the construction of a high speed fibre-optical network.

The cities probably have more projects in mind, as they have organized a German-Chinese Smart City forum in Rüsselsheim in September 2014.

Huawei itself defines the key aspects of Smart City on its website as follows:

In a nutshell, a Smart City describes the integrated management of information that creates value by applying advanced technologies to search, access, transfer, and process information

If I simplify this sentence, Smart City is information management. Like a database.

Huawei further lists the following application areas (in this order):

  • Government and administration (e-government)
  • Traffic management (e-traffic)
  • CCTV (Video surveillance)
  • Health and education (e-health and e-education)
  • Home Monitoring (e-Home)

Next these technical requirements are listed:

A Smart City needs to support services like E1, E3, DS3, STM-1, PRI, ATM, FR and X.25

Overall, Huawei offers a very technical interpretation of the concept Smart City. This is of course not so surprising, as they want to sell the needed technologies. Compare this to other interpretations in my article “Smart City, one term, many concepts

WebApp-Icons für Chrome auf Android

Translation to english is in progress, stay tunes

Webapps sind im Grunde einfach Webseiten, die man mit eigenen Icon auf seinen Smartphone installieren kann. Die Nutzer brauchen so nicht über einen Appstore zu gehen.

Um eine solche Webapp zu entwickeln müssen wir dem HTML-Code einer Webseite zusätzliche Informationen mitgeben: die generelle Eigenschaft “WebApp-fähig” sowie mindestens ein Icon. Apple hat sich hier ein Link Element mit Namen “apple-touch-icon” ausgedacht, zunächst in der krummen Größe von 57 Pixel. Dann kamen neue Geräte und Auflösungen, und Ruck-Zuck durfte man 4 verschiedene Icons allein für Apple definieren.

Android hat WebApps bisher zwar auch unterstützt, aber eher halbherzig. Und Android möchte gerne andere Icon-Größen haben, die Vielfalt ist noch höher als bei Apple. Die Icon-Größen sind hier 48/72/96/144/192. Natürlich wollte die Android-Entwickler nicht die Tags nutzen, die das Wort “Apple” im Namen haben. All diese Bilder müssen im Kopfbereich der HTML-Datei verlinkt werden. Der Kopfbereich wird dadurch immer größer, ohne das irgend ein substanzieller Inhalt hinzukommt.

The new solution

Mit Chrome ab Version M39 hat sich Google jetzt der WebApp-Funktionalität noch einmal angenommen. Die Lösung ist eine zusätzliche Datei, die von der Originaldatei mit einem Link-Element referenziert wird:

<link rel=”manifest” href=”manifest.json”>

Der Browser braucht die Informationen in der Datei nur anfordern, wenn der Nutzer wirklich die WebApp auf den Startbildschirm installieren will. In der Datei können wird die verschiedenen Icons definieren, sowie einige nützliche Extra-Informationen:

  • name: Der Name, der auf dem Startbildschirm erscheinen soll. Der sollte möglichst kurz sein, also oft anders als der HTML-Title.

  • orientation: Man kann landscape oder portrait als Ausrichtung festlegen.

  • start_url: Das ist meistens einfach “index.html”

  •  

    display: “standalone” Dieses Attribut schaltet die Webapp Funktionalität in Chrome an.

Result

Die Auslagerung der Web-App-Definition macht den Head-Bereich von Webseiten wieder kleiner (oder zu mindestens wächst er nicht mehr mit jeder neuen Icon-Größe).

Das gewählte Format ist offenbar wieder mal ein Alleingang einer amerikanischen Firma. Weder CSS noch der ebenfalls “Manifest” genannte Appcache-Definition, noch die XML-Widget-Definition des W3C wurden verwendet. Leider fehlt bei Chrome immer noch eine definierte Möglichkeit, wie die WebApp erkennen kann, dass sie im Standalone-Modus läuft.