I'm trying to install the Rails Admin Gem using Sorcery for authentication instead of Devise.
Rails admin does provide a hook that you can use to attach your own authentication method. Here is the example they provide in their docs (using warden):
config.authenticate_with do
warden.authenticate! :scope => :admin
end
config.current_user_method { current_admin }
I'm guessing that inside the block I need to reference the before_filter
that Sorcery uses to authenticate users, which would be require_login
.
However, when I try that and I try to visit /admin
when logged out, I get a routing error:
No route matches {:action=>"new", :controller=>"sessions"}
This probably happens because I am being redirected within the engine rather than in the main app.
How can I set this up correctly?
If you use Sorcery with Cancancan gem, you should also add
config.current_user_method(&:current_user)
in yourconfig/initializers/rails_admin.rb
file, or you'll get the error:You are not authorized
.