Skip to content
This repository was archived by the owner on Oct 19, 2018. It is now read-only.
This repository was 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

@sfcgeorge

Description

@sfcgeorge

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions