gem_rbs_collection icon indicating copy to clipboard operation
gem_rbs_collection copied to clipboard

activerecord: Add types for `from` to ActiveRecord ClassMethods

Open dak2 opened this issue 5 months ago • 1 comments

Currently, the from method is defined for the ActiveRecord::QueryMethods class, but not for the class method of the ActiveRecord type.

Therefore, User.from(something) is a type error.

However, from is actually used to chain model classes to retrieve records.

The related file in rails/rails has a comment about this. See the link below.

ref. https://github.com/rails/rails/blob/a11f0a63673d274c59c69c2688c63ba303b86193/activerecord/lib/active_record/relation/query_methods.rb#L1359-L1368

dak2 avatar Jun 30 '25 09:06 dak2

@dak2 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

activerecord

You changed RBS files for an existing gem. You need to get approval from the reviewers of this gem.

@hibariya, @ksss, @Little-Rubyist, @tk0miya, please review this pull request. If this change is acceptable, please make a review comment including APPROVE from here. Screen Shot 2024-03-19 at 14 13 36

After that, the PR author or the reviewers can merge this PR. Just comment /merge to merge this PR.

github-actions[bot] avatar Jun 30 '25 09:06 github-actions[bot]

Thanks for your review, @ksss!

@dak2, @ksss This PR is ready to be merged. Just comment /merge to merge this PR.

github-actions[bot] avatar Jul 01 '25 02:07 github-actions[bot]

/merge

dak2 avatar Jul 01 '25 02:07 dak2