Tapioca によって生成された rbi に Devise current_user メソッドが含まれていないのはなぜですか?
概要
Sorbet を使用する Rails プロジェクトに Devise を追加しようとしています。 Deviseを追加した後、bundle exec tabioca dslとbundle exec tabioca gemを実行しました。現在、私のコントローラーでは、型チェックで current_user ヘルパー メソッドが見つからないというエラーが発生しています。
生成されたファイル sorbet/rbi/gems/[email protected] に次の説明が含まれていることに気付きました。
class << self
# Define authentication filters and accessor helpers based on mappings.
# These filters should be used inside the controllers as before_actions,
# so you can control the scope of the user who should be signed in to
# access that specific controller/action.
# Example:
#
# Roles:
# User
# Admin
#
# Generated methods:
# authenticate_user! # Signs user in or redirect
# authenticate_admin! # Signs admin in or redirect
# user_signed_in? # Checks whether there is a user signed in or not
# admin_signed_in? # Checks whether there is an admin signed in or not
# current_user # Current signed in user
# current_admin # Current signed in admin
# user_session # Session data available only to the user scope
# admin_session # Session data available only to the admin scope
#
# Use:
# before_action :authenticate_user! # Tell devise to use :user map
# before_action :authenticate_admin! # Tell devise to use :admin map
#
# source://devise//lib/devise/controllers/helpers.rb#112
def define_helpers(mapping); end
end
これらのメソッドを Bundle exec srb tc で正しく識別するには何か足りないものはありますか?
ApplicationController クラスに Devise::Controllers::Helpers を含めようとしましたが、役に立ちませんでした。
解決策
そこで作成した GitHub の問題に関するタピオカ リポジトリで回答を入手しました。
カーン・オズカンからの回答を引用します。