KyivKrishnaAcademy/ved_akadem_students

View on GitHub
app/policies/paper_trail/version_policy.rb

Summary

Maintainability
A
25 mins
Test Coverage
A
100%
module PaperTrail
  class VersionPolicy < BasePolicy
    def show?
      if record.is_a?(PaperTrail::Version)
        object = record.reify || record.item || record.next&.reify
        policy = Pundit.policy(user, object)

        if policy
          policy.show?
        else
          ::Rails.logger.warn("Couldn't find policy VersionPolicy for #{object.class}")

          super
        end
      else
        super
      end
    end
  end
end