Year: 2015

Validate a checkbox in Rails

If you have to validate a checkbox in your frontend that is part of your model (e.g. acceptregulation) the following snippet works like charm.


Display html in Rails form from l18n/translations

To display html without html encoding you have to use the .html_safe method for the translation:




Rails translating booleans in I18n files

While I was working on a multilingual project I came across a label issue for booleans. In my application the field approved is boolean field and displays by default true or false. I want it to display yes or no; and ja and nein in German. more

Replace mulitple characters in a Java string

In Java Strings are immutable, so you cannot change something in a String without creating a new one.

Manipulation of characters at certain positions can be done best by using the StringBuilder class. It is a special class for String manipulation and creation. more