Skip to content

Commit

Permalink
update wiki_policy
Browse files Browse the repository at this point in the history
  • Loading branch information
TeriPastorino committed Jul 13, 2015
1 parent 9673f6f commit 2a75ea9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
5 changes: 3 additions & 2 deletions app/controllers/wikis_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
class WikisController < ApplicationController
def index
@wikis = policy_scope(Wiki)
#authorize @wikis
# @wikis = policy_scope(Wiki)
@wikis = Wiki.all
authorize @wikis
end

def show
Expand Down
2 changes: 1 addition & 1 deletion app/policies/application_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def index?
end

def show?
scope.where(id: record.id).exists?
scope.where(:id => record.id).exists?
end

def create?
Expand Down
9 changes: 8 additions & 1 deletion app/policies/wiki_policy.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
class WikiPolicy < ApplicationPolicy
class Scope < Scope
def index?
true
end

def destroy?
user.present? && (record.user == user || user.admin?)
end

def resolve
scope
end

end
end

0 comments on commit 2a75ea9

Please sign in to comment.