Tumbling with Ryan
31 Oct 07

New before_filter semantics

Something I posted on the ELC Tech Blog at: here 


It looks like Rails 2.0 will no longer pay attention to the return value of before_filters.  Currently, in our Pre-Rails 2.0 world, before_filters stop processing a request when they encounter a return value of false.  You may recognize the common pattern:




  redirect_to new_session_path && return false



Rails 2.0 won’t require a return value of false for a before_filter to stop the action, but will instead look to see if you called redirect_to or render.  If either of these functions are called the filter chain is halted.  This should clean up a lot of code and remove a lot of repetition.  At the end of the day your before filters look almost the same as they always have, just drop the && return false.