0
我試圖用權威人士驗證訪問需要任何數據庫交互的一些靜態的觀點:權威人士:未定義的方法`授權」
class StaticController < ApplicationController
include Pundit
authorize :splash, :home?
def home end
end
下面是我的靜態策略。 home?
策略總是返回true,所以我應該能夠訪問主視圖。
class StaticPolicy < Struct.new(:user, :static)
def initialize(user, resource)
@user = user
@resource = resource
end
def home?
true
end
end
相反,我得到這個:
undefined method `authorize' for StaticController:Class
權威人士完美的作品,如果我授權模式:
def forums_index
@forums = Forum.all
authorize @forums
end
但是,如果我嘗試使用授權法的外部行動,不使用我得到的模型:
undefined method `authorize' for StaticController:Class