Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PrivateRelation is not aware of class methods #2118

Closed
rzane opened this issue Dec 7, 2024 · 1 comment
Closed

PrivateRelation is not aware of class methods #2118

rzane opened this issue Dec 7, 2024 · 1 comment
Labels
help-wanted We support this change, and welcome community contributions for it.

Comments

@rzane
Copy link
Contributor

rzane commented Dec 7, 2024

ActiveRecord provides two ways to define scopes. The first is scope, which Tapioca generates RBI definitions for. ActiveRecord also allows scopes to be defined as class methods:

class Post < ActiveRecord::Base
  def self.published
    where(published: true)
  end
end

Tapioca's PrivateRelation doesn't include these scopes. Referring to one of these scopes produces a type error:

Post.all.published
         ^^^^^^^^^ Method published does not exist on Post::PrivateRelation
@rzane rzane changed the title PrivateRelation makes is not aware of class methods PrivateRelation is not aware of class methods Dec 9, 2024
@amomchilov amomchilov added the help-wanted We support this change, and welcome community contributions for it. label Dec 9, 2024
@paracycle
Copy link
Member

This is not how Active Record works, so this will not be represented by Tapioca by adding these methods to relation classes.

See #2119 (comment) and #1994 (comment) for more information.

@paracycle paracycle closed this as not planned Won't fix, can't repro, duplicate, stale Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help-wanted We support this change, and welcome community contributions for it.
Projects
None yet
Development

No branches or pull requests

4 participants
@paracycle @rzane @amomchilov and others