For some reason, I am getting an error when clicking on a protected part of my page:
Firefox: The page isn't redirecting properly
Here is the method I use in my ApplicationController:
protected
  def authorize
    unless User.find_by_id(session[:remember_token])
      flash[:notice] = "Please Log in"
      redirect_to :controller => 'sessions', :action => 'new'
    end
  end
For some reason, I am not getting access to sessions/new, which is my login page. Any help would be very much appreciated. I checked routes and I have get sessions/new.
As a well educated guess, I'd say you have this:
before_filter :authorize
Which will keep redirecting to itself.
You can fix this either by passing only the ones you want:
before_filter :authorize, :only => [:action_a, :action_b]
Or specify the ones you don't want (probably preferable if you only want to stop your sessions#new action
before_filter :authorize, :except => [:new, :create]
If your before_filter is specified on an inherited controller (e.g. your SessionsController is inheriting the before_filter from ApplicationController) then you can use skip_before_filter
skip_before_filter :authorize, :only => [:new, :create]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With