Enable private doodads
This commit is contained in:
parent
c661d85727
commit
79b3b21aba
@ -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
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
@ -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?
|
||||||
|
|||||||
@ -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)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user