How to solve the naked domain problem and forward to (non-www to www)

A problem every web developer has when starting with a new project is

Do I want to use or as the URL for my fancy new thing?

This is called the "canonical URL" and it's fairly important that you choose one option and stick to it. If you choose to use the www subdomain, all traffic to the non-www URL should forward to it and keep the path intact, e.g. should foward to

Which option to choose is up to you, there is no right or wrong answer, although many people argue that the www subdomain is not necessary nowadays since it comes from a time where ftp, gopher, telnet were other equally-important subdomains. Many short domains opt to use the non-www version, presumably to make their domain appear even shorter, and it also seems common for .io and .co domains.

Read on

A nifty service layer for your Rails app

If you have been in the Rails world for a while, you have undoubtedly heard about the discussion around whether, as a Rails app grows in size, it needs an additional "service layer" that contains all the business logic. There have been many blog posts about this topic already so I won't repeat the pros and cons here.

Not sure if I need a service layer or just put it all in /lib

I for one started using services as an experiment in a couple of Rails apps I am working on/maintaining in early 2013 and must say, it has made working on these apps enormously more pleasant! Everything from reasoning about the way the apps work to finding bugs or implementing new features has become much more enjoyable!

Read on

code.talks 2014 conference in Hamburg

I am not a big fan of developer conferences I have to admit - too few good talks, too much awkward talk about the latest nerd stuff. The last few conferences haven't been much of an exception, yet I always sign up to new ones thinking I have to "get out there" and can't just work on my own all the time.

Then, when I'm at the conference, what I mostly do (after a few of those awkward nerdy talks) is sit in a quiet corner and work on my projects. Granted, doing that is very nice, since you are surrounded by developers, which is a great environment to be in when coding, but it's not the sole purpose of a going to a conference, now is it?

Read on

Spotcar im Test - was kann der neue Konkurrent zu DriveNow, Car2Go und Multicity?

Spotcar im Test - was kann der neue Konkurrent zu DriveNow, Car2Go und Multicity?

Normally I blog here in English about programming stuff, this post is an exception since it's in German and about a new carsharing provider in Berlin.

Update (12.5.2015): Spotcar ist pleite!

Gestern, am 21. August 2014, ist Spotcar, der neue Carsharing-Anbieter von Opel, offiziell in Berlin gestartet. Da ich ein großer Carsharing-Enthusiast und regelmäßiger Nutzer von fast allen Anbietern (DriveNow, Car2Go, Multicity, Stadtmobil, Flinkster und Citee) bin, habe ich es mir nicht nehmen lassen, sofort eine Testfahrt zu unternehmen.

Das Ergebnis war leider nicht durchweg positiv, aber ich hoffe, es handelt sich bei allen Mängeln, die mir aufgefallen sind, um sogenannte Kinderkrankheiten.

Read on

Extract your common Ruby gems for increased maintainability

After six years of writing Rails apps, for clients as well as side projects (and not-so-side projects), I started seeing a clear pattern in my Gemfiles, namely a bunch of gems I used over and over again.

Well, actually I probably started seeing those patterns already on the third or fourth Rails app, but by now I can be fairly certain that there are some gems that I will want to use in every project I work on.

Read on

Bringing Bootstrap and Ruby together

I've always been a huge fan of Bootstrap, the front-end framework started by two former Twitter employees. For me as a design-impaired programmer, it meant I could build front-ends for my projects all by myself, and they wouldn't look absolutely horrible.

Since I create all of my projects in Ruby (web apps as well as web sites), over the years I have searched for, found, and used (or not found and created myself) my fair share of Ruby wrappers for the different components Bootstrap offers. Often, when I found yet another Bootstrap related Ruby project on Github that did the same as another one, I have wished for a curated collection of those tools, which is exactly what I want to introduce in this post.

Read on

Introducing RubyDocs - Fast and searchable Ruby and Rails docs

Update June 1 2014: RubyDocs is now mentioned as reference documentation on the official Ruby website (look for "Ruby & Rails Searchable API Docs")!

Update May 25 2014: The source code for RubyDocs is now open source under the MIT license and available on Github. If you have any ideas for new features or run into any bugs while using RubyDocs, please open an issue!

RubyDocs was already launched at the end of 2013 but a few days ago I added the most-asked-for missing feature (being able to generate docs for just Ruby or Rails) and noticed that I have never officially introduced the project in a blog post, so here we go.


  • RubyDocs allows to you to generate sdoc docs for any version of Ruby or Rails (or both combined).
  • sdoc is awesome! (it also powers the official Rails API docs)
  •, which used to let you create sdoc docs, has been defunkt for a long time now, which is why I set out to build a replacement.
  • Does anyone know Vladimir Kolesnikov? He owns and I tried to get in touch with him to ask him to forward to but didn't get an answer.
Read on

How to migrate your websites from UptimeRobot to StatusCake with Ruby

UptimeRobot, which I have been a happy user of since 2010, has been failing me in the last months, reporting hundreds of false downtime alerts for my 34 websites monitored by them. Since beginning of March it has been particularly bad with 20-30 false alerts per day.

I tried to get in touch via Twitter and email a couple of times but received no response so it was time to say goodbye.

Read on

Load remote Rails links and forms in Bootstrap modals

As a heavy user of Bootstrap modals and Rails, I often want to use remote links or forms in a modal and load the result into the same modal. After doing this in several projects I worked on, I now copy and paste the helper directly into any new project I start that will use modals:

$(document).on 'ajax:success', '.modal [data-remote="true"]', (_, data) ->
      scrollTop: 0
      , 300

The trick is to specify only [data-remote="true"], not a[data-remote="true"] or form[data-remote="true"] so it works with remote links and forms. As you see, I also added a animation that scrolls to modal to the top after inserting the new content.

This helper works with Bootstrap 2.x and 3.x.

Read on

Get query parameter from the current URL with Javascript

When working with Javascript, you sometimes want to fetch the value of a query parameter from the current URL. I found multiple jQuery plugins to do this (in the horrible tradition of writing jQuery plugins for the most miniscule and simplest of tasks) but I ended up writing it myself in seven lines of Coffeescript (and I'm sure it could be compressed to one or two).

Update: as pointed out in the comments, my method has the flaw that it doesn't escape the query parameter it looks for, so it certain circumstances it might match the wrong parameter. If that concerns you, I would recommend to use this alternative method.

Check it out:

getQueryParam = (param) ->
  regex = new RegExp("[?&]#{encodeURIComponent(param)}=([^&]*)")
  match = regex.exec(
  if match?
Read on