Skip to content

Conversation

@okuramasafumi
Copy link

Previously, we needed to add our own handwritten type to AR model.

class Talk < ApplicationRecord
  class ActiveRecord_Relation
    def page: (untyped) -> self
    def per: (Integer) -> self
  end
end

This is fixed by this Pull Request.

Previously, we needed to add our own handwritten type to AR model.

```rbs
class Talk < ApplicationRecord
  class ActiveRecord_Relation
    def page: (untyped) -> self
    def per: (Integer) -> self
  end
end
```

This is fixed by this commit.
@github-actions
Copy link

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

kaminari-activerecord

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.

@Little-Rubyist
Copy link
Contributor

I’m checking this because I think we might also need to update the tests. :loading:

@okuramasafumi
Copy link
Author

OK, so now I noticed that what is a problem.
The example below works:

Talk.page(1).per(10)

But this doesn't:

Talk.all.page(1).per(10)

I believe it's because all returns a type which we don't expect. I have not investigated it well yet, though.

@ksss
Copy link
Collaborator

ksss commented Nov 5, 2025

page method of kaminari can be dynamically changed by configuration.

https://github.com/kaminari/kaminari/blob/master/README.md#changing-page_method_name

If we fix the name here, it may be useful for many applications that have not changed their settings, but it may cause confusion for some applications that have changed their settings.
For more correct typing, I recommend writing types that match the configuration on the application side.

@okuramasafumi
Copy link
Author

page method of kaminari can be dynamically changed by configuration.

Right, but if it's not common, adding page method makes sense. Writing types manually could be optional.

@ksss
Copy link
Collaborator

ksss commented Nov 7, 2025

In RBS, we cannot redefine the same method name, nor can we invalidate existing definitions.
Optional means would require advanced hacks.

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.

3 participants