dan.hatfield
2007-May-17 13:42 UTC
Upgrading to rails 1.2.3 from 1.1.6 - problem with redirect_to and DoubleRender
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.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Tobes
2007-Jun-05 01:35 UTC
Re: Upgrading to rails 1.2.3 from 1.1.6 - problem with redirect_to and DoubleRender
Have you tried using... redirect_to(:controller => "login" , :action => "login" ) and return false ...? T On May 17, 11:42 pm, "dan.hatfield" <dan.hatfi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---