Sha256: 84684610fac592ae31fe4d0b56ab42c6039a71369ac95aac8faf28f35c859242
Contents?: true
Size: 724 Bytes
Versions: 24
Compression:
Stored size: 724 Bytes
Contents
module Proclaim class PostPolicy < ApplicationPolicy def index? true # Anyone can list posts end def show? if @user true # A logged in user can see anything else @record.published? # Guests can see published posts end end def create? not @user.nil? # As long as there's a user, it can create posts end def update? not @user.nil? # As long as there's a user, it can update posts end def destroy? not @user.nil? # As long as there's a user, it can destroy posts end class Scope < Scope def resolve if @user scope.all # Users can access all posts else # Guests can see all posts that are published scope.published end end end end end
Version data entries
24 entries across 24 versions & 1 rubygems