class ApplicationPolicy
  attr_reader :user, :record

  def initialize(user, record)
    @user = user
    @record = record
    @accepted_admin_roles = [
      :admin
    ]
  end

  def index?
    false
  end

  def show?
    scope.where(:id => record.id).exists?
  end

  def create?
    false
  end

  def new?
    create?
  end

  def update?
    false
  end

  def edit?
    update?
  end

  def destroy?
    false
  end

  def scope
    Pundit.policy_scope!(user, record.class)
  end

  class Scope
    attr_reader :user, :scope

    def initialize(user, scope)
      @user = user
      @scope = scope
    end

    def resolve
      scope
    end
  end
end

class ApplicationPolicy
  attr_reader :user, :record

  def initialize(user, record)
    @user = user
    @record = record
    @accepted_admin_roles = [
      :admin
    ]
  end

  def index?
    false
  end

  def show?
    scope.where(:id => record.id).exists?
  end

  def create?
    false
  end

  def new?
    create?
  end

  def update?
    false
  end

  def edit?
    update?
  end

  def destroy?
    false
  end

  # Used this in views to test for listing admin links
  #
  # ex: <%= if policy(User).view_admin? %>
  #     <%= link_to "Users", users_path %>
  #      <% end %>
  def view_admin?
    false
  end

  def scope
    Pundit.policy_scope!(user, record.class)
  end

  class Scope
    attr_reader :user, :scope

    def initialize(user, scope)
      @user = user
      @scope = scope
    end

    def resolve
      scope
    end
  end
end

Add view_admin? method to ApplicationPolicy
Add view_admin? method to ApplicationPolicy

We have numerous places in our views where we need to list admin links
to different resources. Sometimes the logic that decides if a user can
see these links does not align with any of the crud verb methods that
are used by default in pundit. In those cases, we have add the
view_admin? method to control the display of these links.
