Rails 4, Authorization issue

250 Views Asked by At

I am using Rails 4 with devise, warden, declarative authorization and omniauth.

When i run the rails server to try and test my initial setup, I get an error message with all of my initial pages.

When i type go to localhost:3000 - i get an error that reads "Invalid strategy some_external_strategy" the error directs me to the application controller - with this method:

 def set_current_user
 Authorization.current_user = current_user
 end

I get the same error with every one of the views that were automatically created as part of the scaffolding generated.

When I try to navigate to localhost:3000/home/index, i get an error that reads: "No route matches [GET] "/home/index"

My routes file has the following in the first line:

root :to => 'home#index'

I have a home_controller.rb that has the following code in it:

class HomeController < ApplicationController

def index

end
end

Any thoughts or advice as to how to fix this issue would be very much appreciated.

Many thanks in advance.

2

There are 2 best solutions below

0
Ram Prabu On

As per my understanding devise gem is moreover comfortable for authentication not for authorization. If you want to do user authorization, I would suggest you to go with CanCan gem rather than using devise. It is simple & efficient gem for authorization purpose.

0
Halogen On

Did you modify config/initializers/devise.rb? I had the same error when I uncommented the Warden configuration part, which includes the following lines:

config.warden do |manager|
    manager.intercept_401 = false
    manager.default_strategies(scope: :user).unshift :some_external_strategy
end