pocke / rbs_rails

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can not use with library 'activestorage'

ksss opened this issue · comments

It cannot be used with activestorage, which is currently added at ruby/gem_rbs_collection#61.

It has the following problems.

activestorage creates key and filename columns.
Current rbs_rails will automatically create a rbs definition for these column, but gem_rbs_collection's activestorage also has a definition for the ActiveStorage::Blob#key and ActiveStorage::Blob#filename method, so the definitions overlap.

The cause is in the implementation in ActiveStorage.

https://github.com/rails/rails/blob/9f02d2d84ac84827b98add4199a7efafd0124eba/activestorage/app/models/active_storage/blob.rb#L109-L123

In ActiveStorage, ActiveStorage::Blob#key and ActiveStorage::Blob#filename are redefined.


The following is my idea.

ActiveStorage::Blob#filename returns ActiveStorage::Filename object, so it needs rbs definition. (It is still untyped for now.)
Therefore, I think rbs_rails should not generate rbs definitions for ActiveStorage::Blob#key and ActiveStorage::Blob#filename.

I am going to implement a solution to this problem.

Thanks for reporting the issue!

ActiveStorage::Blob#filename returns ActiveStorage::Filename object, so it needs rbs definition. (It is still untyped for now.)
Therefore, I think rbs_rails should not generate rbs definitions for ActiveStorage::Blob#key and ActiveStorage::Blob#filename.

Looks good, go ahead 👍


By the way, I'm a little busy in a week, and I'm not familiar with Active Storage. So probably I'll have a delay to review if you'll make a pull request. 🙏

Workarounds are easy.

Enjoy the road trip 🚗

I'll close this issue because this is solved by #192, but feel free to re-open this issue if you still have any related problems. Thanks!