Uninitialized persistent DashboardController for localhost: when access to the site area is accepted by the administrator

Hi, I have a problem with the "uninitialized persistent DashboardController" when I open my site with localhost: 3000. This shows me the above error. it does not allow me to enter a user.

I have many models for the administrator as well as users, so I need a solution for this error.

y this is so .... and I define root: to => 'home / index' as my root file, so whenever I write localhost in my browser, it does not load.

I installed the program for the user and administrator Active-admin for the administrator.

// for devise user session controller :sessions do get 'login' => :new post 'login' => :create delete 'logout' => :destroy end root :to => 'home#activity_list' //for localroot 


New question and its answer:


If you get this error then jus will do it.

Processing by Admin :: DashboardController # index as HTML Completed 401 Unauthorized in 1 ms

This occurs when you try to open localhost: 3000 / admin and redirect to localhost: 3000 / usres / sign_in

then you can add these three lines, so copy these three lines and paste them at the bottom of the file (after ActiveAdmin.setup do | config | .... end) in config / initializers / active_admin.rb.

  ActiveAdmin::BaseController.class_eval do skip_before_filter :authenticate_user! end 

I actually have

before_action: authenticate_user!

in my controller_ application.

Just open ActiveAdmin :: BaseController and put skip_before_filter here.

+7
source share
1 answer

In routes.rb:

  root :to => 'frontpage#index' # MUST be before ActiveAdmin (as SSR said) devise_scope :users do # Must also be before ActiveAdmin root :to => "frontpage#index" end namespace :admin do root to: 'users#index' # if you want to be on user by default on the admin #resources :dashboard <= Remove this line if you have it end devise_for :admin_users, ActiveAdmin::Devise.config ActiveAdmin.routes(self) devise_for :users, :controllers => {:omniauth_callbacks => 'omniauth_callbacks'} ActiveAdmin.routes(self) 

If you have a uninitialized constant DashboardController error, just delete everything in app/helpers/admin/


Another method is to simply add the is_admin column to your user table.

Then add this to initializers/active_admin.rb :

 config.authentication_method = :authenticate_admin_user! config.current_user_method = :current_admin_user 

And this is in application_controller.rb

 def authenticate_admin_user! if !current_user.is_admin flash[:error] = "You must be admin to access this page." redirect_to root_path return end end 

This way you do not need the admin_user table. Just change is_admin from 0 to 1 so that the user becomes an administrator.

+2
source

All Articles