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 has been archived by the owner on Jul 5, 2023. It is now read-only.
SorbetRails doesn't currently generate methods for ActiveStorage attachments. For example, in my Rails app users have avatars and games have covers, but neither of these are typed.
moduleGame::GeneratedAttributeMethodsextendT::Sigsig{returns(T.nilable(ActiveStorage::Attached::One))}defcover;endsig{params(attachable: T.untyped).returns(T.untyped)}defcover=(attachable);end# or, if we had something defined like `has_many_attached :covers`sig{returns(T.nilable(ActiveStorage::Attached::Many))}defcovers;endsig{params(attachable: T.untyped).returns(T.untyped)}defcovers=(*attachables);endend
I'm not entirely sure what the setters take or return, unfortunately.
Versions:
Ruby: 2.6.2
Rails: 6.0.0
Sorbet:
Sorbet-Rails: 0.5.3 (master)
The text was updated successfully, but these errors were encountered:
On Thu, Aug 29, 2019 at 7:02 PM Connor Shea ***@***.***> wrote:
I think you can get attachment names for a model like this
User.attachment_reflections.keys# => ["avatar"]
You can also get the type of attachment (has_one_attached vs
has_many_attached) like this:
User.attachment_reflections.values.map { |x| x.class }# }=> [ActiveStorage::Reflection::HasOneAttachedReflection]
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#148?email_source=notifications&email_token=AAFH4ANVHE4JMYJBRVEKW3LQHB5URA5CNFSM4ISIMBTKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5QKABA#issuecomment-526426116>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAFH4ALNAND5D5TKPM4LHB3QHB5URANCNFSM4ISIMBTA>
.
Describe the bug:
SorbetRails doesn't currently generate methods for ActiveStorage attachments. For example, in my Rails app users have avatars and games have covers, but neither of these are typed.
Steps to reproduce:
In
hidden.rbi
we have some methods like this:Expected behavior:
It should return either
ActiveStorage::Attached::One
orActiveStorage::Attached::Many
depending on the definition in the model.This is what I'd expect to see in
game.rbi
:I'm not entirely sure what the setters take or return, unfortunately.
Versions:
The text was updated successfully, but these errors were encountered: