MettaProgramming

Thoughts on Software and Technology

Rails, Authlogic, and strange errors like “user_url”

one comment

Alright, this may be obvious to you real rubologists, but I’ve only been programming in Ruby for about a week, and Rails is still a framework where I have to rebuild my projects frequently because I bork them so bad.

My hope is that there’s someone else who’s as clueless as me. If that person is out there, and happens to get strange errors with Rails, maybe using Authlogic, maybe this will help.

ActionController::RoutingError in Users#show

Alright, so you’re building a Rails app, and you have no damn clue what the hell you’re doing, and you still decided to get all complicated and have completely useless and meaningless things like “users” and “sessions” and “logins.”

Well, it’s your own damn fault when you get some strange error like1

user_url failed to generate from {:action=>"show", :controller=>"users"}

especially when you know damn well that the frackin’ controller is there and the show method works because you just used it 2 minutes ago and everything worked just find thank you very much!!!

Look, I told you it’s your own damn fault for getting complicated.

Sessions are like cactuses, they’re pointy and hurt, but pretty in Ansel Adams pictures

Yes, by the way, I know that the plural is technically cacti, but I’m going for comedic effect.

So, the deal is, the authentication token hangs around, and you’ve probably done something stupid like

rake db:drop && rake db:create && rake db:migrate && rake db:seed

just so that you could test some random thing that you don’t understand. Well, if you do that, and you’re using authlogic, and you don’t bother to logout before hand, your session token will remain live in the browser cache and then you will be totally screwed when you suddenly refresh your browser and get strange incomprehensible errors on a webapp that was working fine just thirty $*#(@*! seconds ago!!!

So, kill the server, flush the browser cache, and then do your crazy “let’s delete the entire damn database and fill it with the exact same information that it had in the first place because it makes us feel better” routine.2

Because, as it turns out, it’s not the exact same information.

Sessions are a bitch.

  1. a full traceback is here, for you meatheads who actually get such an error []
  2. By the way, I know this only because I have an incredibly deep understanding of the subtleties of this language, not because I’d be stupid enough to spend the last few hours fighting with something that’s so blatantly simple… just so you know. []

Written by john

January 12th, 2010 at 10:52 pm

Posted in Ruby

Tagged with , ,