devise icon indicating copy to clipboard operation
devise copied to clipboard

Sorbet support for Devise Controllers

Open samarti opened this issue 2 years ago • 3 comments

Environment

  • Ruby 3.1.1
  • Rails 6.1.7
  • Devise 4.9
  • Sorbet 0.5

Current behavior

I've recently started a new Rails 6 project with Ruby Sorbet (https://sorbet.org/). However, I haven't been able to generate RBI (Ruby Interface files) for Devise library controllers (Sessions Controller, Registrations Controller). The only automatically .rbi files generated are for Devise::Models::Authenticatable, Devise::Mailer and Devise::FailureApp

For generating these files I've been using Tapioca (https://github.com/Shopify/tapioca), which has the option of manually generating them (shims) but it's not ideal. So my questions are:

  • Is Sorbet fully supported by Devise?
  • Are there any samples of manually generated .rbi files for static type check support?

Expected behavior

Tapioca should be able to generated .rbi files for Devise controllers

samarti avatar Nov 01 '23 14:11 samarti

Seems like there are maintained annotations for the controllers, so you can just run bin/tapioca annotations and it should grab the appropriate files.

crespire avatar Feb 19 '25 21:02 crespire

Seems like there are maintained annotations for the controllers, so you can just run bin/tapioca annotations and it should grab the appropriate files.

Yeah, I ended up manually creating .rbi shims for all the controllers I needed. Not ideal but it kept Sorbet happy. For example:

/sorbet/rbi/shims/devise/app/controllers: Image

/sorbet/rbi/shims/devise/app/controllers/helpers.rbi: Image

samarti avatar Feb 20 '25 15:02 samarti

Additional context: https://sorbet-ruby.slack.com/archives/CHN2L03NH/p1740001765807089

stathis-alexander avatar Feb 20 '25 22:02 stathis-alexander