私はサイト全体のcancan認証システムを構築しています。私の試みを非常に簡単に検証するために、ページにアクセスしようとするたびにテストケースを初期化しています。
# application_controller.rb
class ApplicationController < ActionController::Base
admin = Role.new(name: :admin, is_default: true)
admin.permissions << Permission.create(action: :manage, subject_class: :all)
admin.save
current_user=User.create!
# users automatically get associations to all roles with `is_default: true`
check_authorization
end
のコントローラーだけskip_authorization_check
が私を通過させ、他のすべてのコントローラーはAuthorizationNotPerformed
エラーをスローします:
CanCan::AuthorizationNotPerformed in ExampleAuthEngin::PermissionsController#index
This action failed the check_authorization because it does not authorize_resource. Add skip_authorization_check to bypass this check.
私は何が間違っているのですか?