Skip to content
This repository has been archived by the owner on Oct 19, 2018. It is now read-only.

Set acting_user within regulate_broadcast on save as well as fetch #104

Open
sfcgeorge opened this issue Jun 28, 2018 · 0 comments
Open

Comments

@sfcgeorge
Copy link
Contributor

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
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant