mammoth-notebook-46426
07/28/2023, 6:24 PMclass ConversationPolicy < ApplicationPolicy
def index?
user.admin?
end
def show?
user.admin?
end
end
ApplicationPolicy
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 # rubocop:disable Style/Documentation
def initialize(user, scope)
@user = user
@scope = scope
end
def resolve
raise NotImplementedError, "You must define #resolve in #{self.class}"
end
private
attr_reader :user, :scope
end
end
What's odd is that when I go to the index for that resource, I can still see the edit and delete icons. This is true in our production environment. In our staging/qa environment, we ONLY see the view icon. So for some reason our staging/qa is following the policy defined, whereas our production environment it's ignoring the policy set up in ApplicationPolicy
. I guess I could try to define the `edit`/`update`/`destroy` policies in ConversationPolicy
outright...but you would think I shouldn't have to.
Any thoughts?lemon-wall-20836
07/28/2023, 6:50 PMmammoth-notebook-46426
07/28/2023, 6:51 PMmammoth-notebook-46426
07/28/2023, 6:51 PMlemon-wall-20836
07/28/2023, 6:52 PMlemon-wall-20836
07/28/2023, 6:52 PMlemon-wall-20836
07/28/2023, 6:52 PMmammoth-notebook-46426
07/28/2023, 6:55 PM