I'm trying to add Devise to my Rails project that uses Sorbet. After adding Devise I ran bundle exec tapioca dsl and bundle exec tapioca gem. Now, on my controllers, the type check is complaining that it can not find the current_user helper method.
I noticed that on the generated file sorbet/rbi/gems/[email protected] it includes the following description:
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
Is there something that I'm missing to have those methods correctly identified by bundle exec srb tc?
On my ApplicationController class, I tried to include Devise::Controllers::Helpers, but that didn't help.
I got the answer on the tapioca repository on this GitHub issue that I created there.
I'm quoting the answer from Kaan Ozkan: