read rails warnings!

Posted by acts_as_flinn Mon, 23 Jul 2007 15:57:00 GMT

I was dealing with an issue today were I was certain my code was right. I was getting the dreaded ActionController::DoubleRenderError error. I was sure I could just redirect_to ... and return but I failed to read the rails warning for the last day or so. The following comes literally right from the development log I’ve been staring at.

ActionController::DoubleRenderError (Render and/or redirect were called multiple times in this action. Please note that you m
ay only call render OR redirect, and only once per action. Also note that neither redirect nor render terminate execution of 
the action, so if you want to exit an action after redirecting, you need to do something like "redirect_to(...) and return". 
Finally, note that to cause a before filter to halt execution of the rest of the filter chain, the filter must return false, 
explicitly, so "render(...) and return false".)

I had a professor in college who used to tell me to read every sentence in a newspaper article because the whole story comes out in the last sentence. There it was plain as day, to halt the filter chain I need to return false, dang!


ss_blog_claim=746d258dc975cb7923cc57154dbf1d71