练习一个 WEB/API 应用,试用 Pandit 做权限管理,请问为什么/controller/api/v1/users_controller.rb 和/controller/users_controller.rb 都指向同一个/policies/user_policy.rb 文件?怎么才能设置指向不同的文件?谢谢。 /controller/api/v1/base_controller.rb
class Api::V1:BaseController < ApplicationController
include Pundit
......
end
/controller/api/v1/users_controller.rb
class Api::V1:UsersController < BaseController
def index
@users = User.all
authorize @users
end
end
/controller/application_controller.rb
class ApplicationController < ApplicationController::Base
include Pundit
......
end
/controller/users_controller.rb
class UsersController < ApplicationController
def index
@users = User.all
authorize @users
end
end
/policies/user_policy.rb
class UserPolicy < ApplicationPolicy
class Scope <Scope
def resolve
end
def index? true end
end