方法
实例公共方法
permissions_policy(**options, &block) 链接
覆盖全局配置的 Feature-Policy
标头的一部分
class PagesController < ApplicationController
permissions_policy do |policy|
policy.geolocation "https://example.com"
end
end
选项可以像 before_action
一样传递。例如,传递 only: :index
仅覆盖索引操作上的标头
class PagesController < ApplicationController
permissions_policy(only: :index) do |policy|
policy.camera :self
end
end
来源: 显示 | 在 GitHub 上
# File actionpack/lib/action_controller/metal/permissions_policy.rb, line 27 def permissions_policy(**options, &block) before_action(options) do if block_given? policy = request.permissions_policy.clone instance_exec(policy, &block) request.permissions_policy = policy end end end