minor cleanup

This commit is contained in:
joshua stein 2012-09-20 10:53:11 -05:00
commit 39bb9b77de
2 changed files with 3 additions and 7 deletions

View file

@ -166,7 +166,8 @@ class Story < ActiveRecord::Base
def check_tags
(self.tags_to_add || []).each do |t|
if !t.valid_for?(self.user)
raise "#{self.user.username} does not have permissions to use privileged tags"
raise "#{self.user.username} does not have permission to use " <<
"privileged tag #{t.tag}"
end
end
end

View file

@ -1,13 +1,8 @@
class Tag < ActiveRecord::Base
attr_accessor :filtered_count
# Scope to determine what tags a user can see
scope :accessible_to, ->(user) do
if user.is_admin?
all
else
where(:privileged => false)
end
user.is_admin?? all : where(:privileged => false)
end
def self.all_with_filtered_counts_for(user)