I have had Devise working in my rails4 app for quite some time already. Now I had a need to add different roles decided to use Cancan to accomplish this.
Everything was working just fine in development but when I deployed code to production all I got was infinite redirect loop. If I delete cookies I can get login page but signing in ends in the same loop.
My root redirects to controllers index action.
I have basically only one controller with any business logic and my root redirects to index action in this controller.
Related lines from the controller.
load_and_authorize_resource
skip_authorization_check :only => [:index]
But I have also tried this:
before_action :authenticate_user!
And in addition previous appended with both of these (separately)
:except => [:index]
:unless => :devise_controller?
In ApplicationController I have both all of these together and separately
check_authorization :unless => :devise_controller?
before_filter :authenticate_user!, :unless => :devise_controller?
And both of these I have tried with and without that unless statement.
I tried following relevant wikis to the letter but can't seem to get this working in production. If it makes any difference I am using Nginx/Passenger combo in production.
While writing this I realized that I have been using Cancan 1.6, I haven't tried Cancancan yet. Will give it a go next.
All help is appreaciated.
UPDATE: I tried this with Cancancan 1.9.2 (Instead of Cancan 1.6) with similar results. I have for the time being disabled it until I find a solution or alternative authorization gem.