Re: Problems w/ before_filter getting ignored

Frederick Cheung
2008-11-05T14:31:48Z

On 5 Nov 2008, at 04:41, Clem Rock wrote:
>
> For some reason, when I login the last request.request_uri address
> that
> is stored in the session is /login.     For some reason, the
> store_location method is still getting called when the login method is
> called and then throws a "Redirect Loop" message in the brower
>
> Here''s the authentication module code:
> [code]
> module Authentication
>  def store_location
>    session[''return-to''] = request.request_uri
>  end
>
>  def login
>    user = User.find_authenticated_user(params[:username],
> params[:password])
>    unless user.blank? || user.nil?
>      session[:user] = user
>    end
>    redirect_to store_location
>  end
> end
>
store_location is getting called because you''re calling it from the
login method :-) You probably meant to do redirect_to session[''return-
to''] (possibly checking whether session[''return-to'']
is nil and
redirecting the user to some where appropriate if that is the case