Rails is like magic…

… but more like black magic. The one where you have to sacrifice kittens to get anything done.

I want to do a simple thing using devise: authenticated users go to a page on the root of the site, and unauthenticated users go to another.
I’ve been banging my head for days on this. Between the various ways to do it, the different ruby, rails and devise versions that use different methods, it’s a mess. Nobody seems to agree on the best way to do it.

Well, I’ve found the way that I believe is the most simple.

Things to remember :

  • “devise_scope” is necessary. I do not understand why, nor what it does.
  • the “as: xxx” parts are necessary, too. It looks like Rails is fine with creating two routes pointing to the same URL, but wants different names for them. I would have tought that it would create these routes only at run-time.
  • do not modify several things at once and hope to understand what went wrong when everything crashes down, as long as you don’t understand the language and framework.