Dion Hewson
2008-Apr-22 15:24 UTC
before_filter halts chain but won''t perform redirect_to properly
I have implemented a simple admin before filter like the one shown on railscasts.com at http://railscasts.com/episodes/20 & http://railscasts.com/episodes/21 but I find that the redirect_to in my authorize function causes the the Filter chain to halt and loop through 20 times with 302 errors trying to redirect to *home_path* before it stops and does not render anything with this error Filter chain halted as [#<ActionController::Filters::ClassMethods::SymbolFilter:0x2aaaabe7b2f8 @filter=:my_authenticate>] rendered_or_redirected. issues_controller.rb before_filter :my_authenticate , :except => {:index, :show} --- application.rb def my_authenticate unless admin? flash[:error] = "unauthorized access" *redirect_to home_path* false end end if I comment out *redirect_to home_path *the app works, but non normal users can access admin paths any tips on why redirect_to breaks the filter chain so i''m running rails 2.0.2 DHH says http://www.ruby-forum.com/topic/128746 so I''d assume the problem I''m seeing should be fixed cheers dion --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Jan Foeh
2008-Apr-22 15:47 UTC
Re: before_filter halts chain but won''t perform redirect_to properly
Based on the fact that it loops dozens of times, is this (or a similar) filter possibly in effect for home_path as well? I.e., /issues/new -> filter -> /home -> filter -> /home -> filter .. ad nauseam -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Dion Hewson
2008-Apr-22 23:47 UTC
Re: before_filter halts chain but won''t perform redirect_to properly
that must be the problem...as the filter is in the same controller as the redirect controller -- my root so I guess the filter is being called over and over.... i''ll try a different tactic now... cheers On Wed, Apr 23, 2008 at 1:17 AM, Jan Foeh <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Based on the fact that it loops dozens of times, is this (or a similar) > filter possibly in effect for home_path as well? I.e., > > /issues/new -> filter -> /home -> filter -> /home -> filter .. ad > nauseam > -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---