Enable private doodads

This commit is contained in:
icwizardmonke 2023-10-14 23:58:44 +00:00
parent 993a28ef21
commit 875c15dc07
4 changed files with 9 additions and 7 deletions

View File

@ -3,7 +3,7 @@ class DoodadsController < ApplicationController
# GET /doodads or /doodads.json
def index
@doodads = authorize policy_scope(Doodad)
authorize @doodads = policy_scope(Doodad)
end
# GET /doodads/1 or /doodads/1.json

View File

@ -2,7 +2,7 @@ class VisitorsController < ApplicationController
before_action :skip_authorization
def index
@doodads = authorize Doodad.all
@doodads = authorize policy_scope(Doodad)
@canisters = authorize Canister.all
end
end

View File

@ -42,11 +42,11 @@ class DoodadPolicy
end
def edit?
@user.admin? || @user == @doodad.user || @doodad.user.nil?
@user.admin? || @user == @doodad.user || (@doodad.is_public? && @doodad.user.nil?)
end
def update?
@user.admin? || @user == @doodad.user || @doodad.user.nil?
@user.admin? || @user == @doodad.user || (@doodad.is_public? && @doodad.user.nil?)
end
def destroy?

View File

@ -1,3 +1,5 @@
.doodad
= doodad.body.html_safe
= link_to 'Edit', edit_doodad_path(doodad)
- if policy(doodad).show?
.doodad
= doodad.body.html_safe
- if policy(doodad).edit?
= link_to 'Edit', edit_doodad_path(doodad)