I'm using Pundit for my authorization, I'm brand new to it and have only previously worked with Cancan and Cancancan.
I have an index page that does not have a model. This page should ONLY be visible to not logged in users (guests only).
I can only seem to get the page to show for everyone or no-one.
application_policy.rb
class ApplicationPolicy
attr_reader :user, :record
def initialize(user, record)
@user = user
@record = record
end
def index?
false
end
def show?
false
end
def create?
false
end
def new?
create?
end
def update?
false
end
def edit?
update?
end
def destroy?
false
end
class Scope
attr_reader :user, :scope
def initialize(user, scope)
@user = user
@scope = scope
end
def resolve
scope.all
end
end
end
splash_controller.rb
class SplashController < ApplicationController
def index
authorize :splash, :index?
end
end
splash_policy.rb
class SplashPolicy < ApplicationPolicy
# def initialize(user, record)
# @user = user
# @record = record
# end
def index?
not user?
end
end
I've commented out a new initialize method, as I assume I need to override this, but I'm not exactly sure on the syntax.