Skip to content

feat(devise): Add types for controller helpers - #1079

Merged
github-actions[bot] merged 1 commit into
ruby:mainfrom
apiology:devise-controller-helpers
Oct 9, 2026
Merged

github-actions[bot] merged 1 commit into
ruby:mainfrom
apiology:devise-controller-helpers

Conversation

@apiology

@apiology apiology commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Claude: This PR was written by Claude Code on behalf of @apiology.

In a Rails app, Devise mixes Devise::Controllers::Helpers into every controller, but the devise RBS doesn't declare it, so type checkers reject sign_in, sign_out, after_sign_in_path_for, devise_parameter_sanitizer, devise_group, etc.:

test.rb:54:4: [error] Type `::ApplicationController` does not have method `sign_in`

This adds Devise::Controllers::Helpers, SignInOut, StoreLocation, Helpers::ClassMethods and Devise::ParameterSanitizer, and includes them into ActionController::Base and ActionController::API, matching devise's ActiveSupport.on_load(:action_controller) hook.

Per-mapping helpers generated at runtime (current_user, authenticate_user!, …) and the UrlHelpers route proxies are not covered.

Devise includes Devise::Controllers::Helpers (with SignInOut and
StoreLocation) into every controller via
ActiveSupport.on_load(:action_controller), but the collection declared
none of it, so sign_in, sign_out, store-location helpers,
after_sign_in_path_for, devise_parameter_sanitizer and devise_group
were unknown on ActionController::Base and ActionController::API.

Declare the three modules, Helpers::ClassMethods, ParameterSanitizer
and MissingWarden, and include/extend them into ActionController::Base
and ActionController::API. Per-mapping generated helpers
(current_user, authenticate_user!, ...) and the UrlHelpers proxies are
not covered.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EhUSLUimEYJyCZv8NdQGKb
@apiology
apiology marked this pull request as ready for review October 9, 2026 14:12
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown

@apiology Thanks for your contribution!

Please follow the instructions below for each change.
See also: https://github.com/ruby/gem_rbs_collection/blob/main/docs/CONTRIBUTING.md

Available commands

You can use the following commands by commenting on this PR.

  • /merge: Merge this PR if CI passes

devise

You changed RBS files for an existing gem.
This gem does not have reviewers. So you can merge this PR immediately if the CI passes.
We recommend you add yourself to the reviewers for this gem.

@apiology

apiology commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

/merge

@github-actions
github-actions Bot merged commit c78df6c into ruby:main Oct 9, 2026
7 checks passed
apiology added a commit to iftheshoefritz/solargraph-rails that referenced this pull request Oct 9, 2026
* Bump gem_rbs_collection to c78df6c for devise helpers

ruby/gem_rbs_collection#1079 added devise's controller helpers
(sign_in, sign_out, signed_in?, after_sign_in_path_for, ...), so the
19 devise entries in actioncontroller.yml now resolve to typed returns
on Solargraph 0.57.0 and later instead of being skipped. 0.51.2 and
0.52.0 still do not see them.

Other collection updates between ed61b16 and c78df6c changed 6 types:

- polymorphic_path, polymorphic_url, render_to_string: String
  (actionpack actiondispatch.rbs, actioncontroller.rbs)
- Rails::Application#configure: void (railties.rbs)
- ActiveRecord::Base.create/create!: Array<self> | self, from the
  activerecord 7.2/8.0 array-argument overloads

0.48.0-0.52.0 do not resolve the new actionpack and railties types and
are skipped.

The activerecord 7.0/7.1 collection files lack the array overload, so
create/create! resolved self on Rails 7.0/7.1 and Array<self> | self on
7.2/8.0 under the same Solargraph version, which version-keyed skips
cannot express. Rails returns an Array from create/create! when given
an Array of attribute hashes on every supported version, so annotate
ActiveRecord::Base.create/create! with that return type; every cell
now resolves Array<self> | self and the skips are removed.

The create/create! types were hand-edited from [self] to
[Array<self>, self]: FORCE_UPDATE only rewrites entries typed
undefined, Object or BasicObject, and adds a skip for any other
mismatch.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EhUSLUimEYJyCZv8NdQGKb

* Key the dot-cache on the RBS collection config

Solargraph 0.57, 0.58 and 0.60.4 rebuild a gem's pins only when
gems/<gem>.ser is missing. The key hashed only the Gemfile.lock files,
so bumping the gem_rbs_collection revision restored pins built against
the old revision and the new types were silently missing.

Hashing spec/**/rbs_collection.yaml into every key tier makes each
collection bump start a fresh cache without a manual prefix change.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EhUSLUimEYJyCZv8NdQGKb

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant