We are using Ruby 2.1 with rails 3.2 and active admin 0.6.3. Our site is up and running on the front end but when trying to access the admin panel, it says:
"NoMethodError (undefined method `authenticate_admin_user!' for Admin::DashboardController"
I've tried searching on net for solutions but none of them worked out.!
Any suggestions?
Edit : Admin user model
ActiveAdmin.register AdminUser do
#menu :priority => 2
menu false
index :title => 'Admin Users'+SiteSetting.site_title do
column :email
column :role do |show|
if show.role=="superadmin"
status_tag('Super Admin', :ok)
elsif show.role=="subadmin"
status_tag('Sub Admin', :ok)
elsif show.role=="customeadmin"
status_tag('Custom Admin', :ok)
else
status_tag('Normal Admin', :ok)
end
end
column 'Current Login', :current_sign_in_at
column 'Last Login', :last_sign_in_at
column 'Login count', :sign_in_count
#current_admin_user[:id]
@count = AdminUser.count
if @count == 1
column do |show|
links = link_to 'View', {:action => show.id.to_s}
links += ' '
links += link_to 'Edit', {:action => show.id.to_s+'/edit'}
links
end
else
default_actions
end
end
controller do
def password
render :text => 'test'
end
def new
@admin_user = AdminUser.new
end
def create
@temp = params[:admin_user][:role_permission]
if @temp ==nil
else
@new_per = @temp.join(',')
params[:admin_user][:role_permission] = @new_per
end
@admin_user = AdminUser.new(params[:admin_user])
@admin_user.save
redirect_to(:action => 'index')
end
def edit
@admin_user = AdminUser.find(params[:id])
end
end
filter :email
sidebar :AdminUserRights do
ul do
li "Super Admin: Can Manage All Pages"
li "Sub Admin: Can Only View And Update All Pages"
li "Normal Admin: Can Only View All Pages"
li "Custom Admin: Customize your admin via giving them custom rights of links"
end
end
form :html => { :enctype => "multipart/form-data" } do |f|
render "create" , :layout => 'active_admin'
end
end
I 've this code added in my application controller file.
Edit : Application Controller
def authenticate_active_admin_user!
authenticate_admin_user!
unless current_admin_user.role?(:superadmin)
flash[:alert] = "You are not authorized to access this resource!"
redirect_to root_path
end
end