Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use Devise and ActiveAdmin for the same User with different login page

I would like to use Devise to log in regular non-admin users with the same User model. So I used role id as another attribute and everything working fine. The challenge is that I have to create the custom login page, registration page and other related pages for front-end user. The current route file is:

Rails.application.routes.draw do
  devise_for :users, ActiveAdmin::Devise.config
  ActiveAdmin.routes(self)
end

Since I want to generate the new login form and want to override the controller I add devise_for :users but it gives me an error route is defined. How could I resolve the conflict?

Also, below is active admin setting:

config.authentication_method = :authenticate_user!
config.current_user_method = :current_user

I want to customize login page and sign up page controller because I have to add few things to signup form.

like image 410
Dinesh Saini Avatar asked Oct 30 '22 04:10

Dinesh Saini


1 Answers

You can override ActiveAdmin in the active_admin.rb config to use the same User model you're using in your application:

So if your primary devise scope is user:

In active_admin.rb

ActiveAdmin.setup do |config|
# ...
  config.authentication_method = :authenticate_user!
  config.current_user_method = :current_user
# ...

http://activeadmin.info/docs/1-general-configuration.html

like image 154
Anthony E Avatar answered Nov 15 '22 07:11

Anthony E