Safest way to avoid RuntimeError_window in authetication?

Hi, I'm using the authentication-process from the Recipes-book. Works fine, only when the user puts in a wrong password or username, I get the RuntimeError-message and -window, from the raise-command. I would much prefer to redirect to some other URL, but because the raise-message is put into the user-model, 'redirect_to' does not work. Anybody with suggestions how to safely redirect here? Thanks in advance.

I'm using the authentication-process from the Recipes-book. Works fine, only when the user puts in a wrong password or username, I get the RuntimeError-message and -window, from the raise-command. I would much prefer to redirect to some other URL, but because the raise-message is put into the user-model, 'redirect_to' does not work. Anybody with suggestions how to safely redirect here? Thanks in advance.

You could either rescue the exception in your controller and then redirect or, perhaps neater, return nil from your model instead of raising an exception and redirect in the controller when you see a nil user.

Regards, Andy Stewart