Enable private doodads

This commit is contained in:
Jesse C. Fisher 2023-10-14 23:58:44 +00:00 committed by icwizardmonke
parent c661d85727
commit 79b3b21aba
4 changed files with 9 additions and 7 deletions

View File

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

View File

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

View File

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

View File

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