Example code from the Apotomo tutorial (http://apotomo.de), reworked for Rails 4.