title: Ruby / Rails CanCanCan Rolify ActiveAdmin
body: <p>I am using RoR, CanCanCan, Rolify, and ActiveAdmin. I can log in and see pages, but cannot login as admin. I am not sure what I am doing wrong here.
  admin/dashboard.rb</p>
  
  <pre><code>ActiveAdmin.register_page "Dashboard" do
  
    menu priority: 1, label: proc{ I18n.t("active_admin.dashboard") }
  
    content title: proc{ I18n.t("active_admin.dashboard") } do
    div class: "blank_slate_container", id: "dashboard_default_message" do
        span class: "blank_slate" do
          span I18n.t("active_admin.dashboard_welcome.welcome")
          small I18n.t("active_admin.dashboard_welcome.call_to_action")
        end
      end
    end
  end
  </code></pre>
  
  <hr>
  
  <p>controllers/application_controller.rb</p>
  
  <pre><code>class ApplicationController &lt; ActionController::Base
   protect_from_forgery with: :exception
  
    def authenticate_active_admin_user!
       authenticate_user!
     unless current_user.role?(:admin)
        flash[:alert] = "You are not authorized to access this resource!"
        redirect_to root_path
     end
      end
  
  end
  </code></pre>
  
  <hr>
  
  <p>models/ability.rb</p>
  
  <pre><code>class Ability
    include CanCan::Ability
  
    if user.has_role? :admin
     can :manage, :all
    else
      can :read, :all
    end
  
    def initialize(user)
  
    end
    can :manage, :all if user.is? :admin
  </code></pre>
  
  <h2>    end</h2>
  
  <p>user.rb
      class User &lt; ActiveRecord::Base
        rolify</p>
  
  <pre><code>  devise :database_authenticatable, :registerable,
           :recoverable, :rememberable, :trackable, :validatable
      def role?(role)
        return !!self.roles.find_by_name(role.to_s.camelize)
    end
  end
  </code></pre>
  
  <hr>
  
  <p>config/initializer/active_admin.rb</p>
  
  <pre><code>ActiveAdmin.setup do |config|
  config.authentication_method = :authenticate_active_admin_user!
  config.current_user_method = :current_user
  config.logout_link_path = :destroy_user_session_path
  config.logout_link_method    = :delete
  config.batch_actions = true
  config.localize_format = :long
  end
  </code></pre>