From e6263b8bdf9037fcea053ce270d7c0a29fb3fbf4 Mon Sep 17 00:00:00 2001 From: Giovanne Marcelo <gms15@inf.ufpr.br> Date: Mon, 28 Mar 2016 11:01:39 -0300 Subject: [PATCH] Small fix --- app/models/collection.rb | 4 ++-- app/policies/collection_policy.rb | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/app/models/collection.rb b/app/models/collection.rb index 227a59eb..05dcce30 100644 --- a/app/models/collection.rb +++ b/app/models/collection.rb @@ -59,9 +59,9 @@ class Collection < ActiveRecord::Base end def user_own?(user) - return false unless user.is_a? User - return user.is_admin? || owner?(user) return true if user.is_a? Institution and owner.users.include?(user) + return false unless user.is_a? User + user.is_admin? || owner?(user) end def private? diff --git a/app/policies/collection_policy.rb b/app/policies/collection_policy.rb index 1b194aa7..06180e1c 100644 --- a/app/policies/collection_policy.rb +++ b/app/policies/collection_policy.rb @@ -12,9 +12,8 @@ class CollectionPolicy < ApplicationPolicy end def resolve - if @user.nil? - scope.where(privacy: 'public') - elsif @user.id == @user_id || @user.is_admin? + + if @user.try(:id) == @user_id || @user.try(:is_admin?) scope.all else scope.where(privacy: 'public') -- GitLab