You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 5, 2023. It is now read-only.
create a method which returns an association relation on a model
classPost < ApplicationRecordbelongs_to:userscope:published ->(){where(published: true)}endclassUser < ApplicationRecordextendT::Sighas_many:postssig{returns(Post::ActiveRecord_AssociationRelation)}defpublished_postsposts.publishedendendRSpec.describeUserdodescribe'#published_posts'doit'returns only the published posts'douser=User.create!published=user.posts.create(published: true)user.posts.create(published: false)expect(user.published_posts).toeq([published])endendend
This would raise a NameError claming that Post::ActiveRecord_AssociationRelation is a private class.
Note as well that in my case the models are on a rails engine.
Expected behavior:
The test passes
Versions:
Ruby: 2.4
Rails: 5.2.3
Sorbet: Sorbet typechecker 0.4.4891 git 4c9a4534439483b46e869c7212007ad103923203 built on 2019-10-17 22:56:24 GMT debug_symbols=true