bug / feature request, acting_user isn't set in regulate_broadcast after a save so I can't use it as I wanted to increase performance of policies by eliminating unnecessary queries. But I can work around by checking for saved_changes?
class CandidateProfilePolicy
regulate_broadcast do |policy|
policy.send_only(
:id, :candidate_id, :avatar
).to(Employer)
if saved_changes? || acting_user&.type&.==("Candidate")
policy.send_only(
:id, :candidate_id, :score, :ethnicity_id,
:driving_level, :avatar, :ethnicity_description, :work_eligibility
).to(candidate)
end
end
allow_change do
acting_user&.id == candidate_id
end
end
bug / feature request,
acting_user
isn't set in regulate_broadcast after a save so I can't use it as I wanted to increase performance of policies by eliminating unnecessary queries. But I can work around by checking forsaved_changes?