Created
January 14, 2014 11:40
-
-
Save mkwiatkowski/8416988 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/app/policies/topic_policy.rb b/app/policies/topic_policy.rb | |
index c247c17..2b4bd00 100644 | |
--- a/app/policies/topic_policy.rb | |
+++ b/app/policies/topic_policy.rb | |
@@ -11,7 +11,7 @@ class TopicPolicy < ApplicationPolicy | |
user.present? && user.role?(:admin) | |
end | |
- def public? | |
- Topic.all.visible_to(user) | |
+ def show? | |
+ user || record.public? | |
end | |
end | |
diff --git a/app/views/topics/index.html.erb b/app/views/topics/index.html.erb | |
index b77332b..9cf6745 100644 | |
--- a/app/views/topics/index.html.erb | |
+++ b/app/views/topics/index.html.erb | |
@@ -1,4 +1,4 @@ | |
-<% if policy(Topic).public? %> | |
+<% if policy(Topic.new).show? %> | |
<h1>Topics</h1> | |
<div class="row"> | |
diff --git a/app/views/topics/show.html.erb b/app/views/topics/show.html.erb | |
index bbb0d07..f0305ae 100644 | |
--- a/app/views/topics/show.html.erb | |
+++ b/app/views/topics/show.html.erb | |
@@ -1,4 +1,4 @@ | |
-<% if policy(Topic).public? %> | |
+<% if policy(Topic.new).show? %> | |
<h1><%= @topic.name %></h1> | |
<% if policy(@topic).update? %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment