null check in synapse policy

This commit is contained in:
Devin Howard 2017-11-13 07:11:48 -08:00
parent f1ecc9eb0b
commit 97448b389f

View file

@ -48,13 +48,13 @@ class SynapsePolicy < ApplicationPolicy
end
def topic1_show?
@topic1_policy ||= Pundit.policy(user, record.topic1)
@topic1_policy&.show?
@topic1_policy ||= Pundit.policy(user, record&.topic1)
@topic1_policy&.show? != false
end
def topic2_show?
@topic2_policy ||= Pundit.policy(user, record.topic2)
@topic2_policy&.show?
@topic2_policy ||= Pundit.policy(user, record&.topic2)
@topic2_policy&.show? != false
end
def synapse_show?