I have a custom authentication plugin that redirects users to a login
site if they aren’t already authenticated and their session hasn’t
timed out. I had things working fine with straight http requests, but
wanted to add support for ajax requests. I thought this would be a
simple matter of replacing all of my “redirect_to and return
false” calls with something like “redirect and return false”,
where the redirect method wraps a respond_to block. For example:
def redirect(url)
respond_to do |wants|
wants.html { redirect_to url }
wants.js { render :update do |page| page.redirect_to url end }
end
end
However, this causes a DRE when I deployed it on my FCGI production
server. In fact, removing the wants.js line so that the function is
just
def redirect(url)
respond_to do |wants|
wants.html { redirect_to url }
end
end
still triggers a DRE. The only time things work as expected are when
the function reads:
def redirect(url)
redirect_to url
end
It seems that the respond_to method is breaking my login plugin. I’m a
little confused as to why this would hapen, though. Has anyone seen
this behavior before?
You can see my plugin’s calls to ‘validate_user_identity’ and
‘redirect’ on the stack, but no calls to ‘redirect_to’ or ‘render’.
Basically, stuff works when I don’t have a respond_to but breaks when
I do have a redirect_to. This is on 1.1.1, fwiw.
–
Ryan
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.