I'm trying to upgrdade from rails 1.1.6 to rails 1.2.3 and I'm running into a difference with redirect_to that is causing a DoubleRenderError.
Here's my code (I'm using a variant of paranoid sql session store):
before_filter :touch_session, :except => [:login, :logout] after_filter :touch_session
def touch_session # NOTE: I rewrote reset_session in action_controller_cgi_request_hack if session[:user_id] == nil flash[:notice] = "Please log in" redirect_to(:controller => "login" , :action => "login" ) else reset_session unless session.host.nil? || session.host == request.remote_ip session.host ||= request.remote_ip session.user ||= session[:user_id] end end
In Rails 1.1.6, this worked fine, in Rails 1.2.3 this throws a DoubleRenderError.
I tried to fix this as so:
def touch_session # NOTE: I rewrote reset_session in action_controller_cgi_request_hack if session[:user_id] == nil flash[:notice] = "Please log in" redirect_to(:controller => "login" , :action => "login" ) return false else reset_session unless session.host.nil? || session.host == request.remote_ip session.host ||= request.remote_ip session.user ||= session[:user_id] return true end end
But that had no effect. Any ideas? I'm sure I'm doing something wrong here but not sure what. There is no other render or redirect after this and since I'm returning false from the before_filter I thought processing should stop.