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

Support activestorage #195

Merged
merged 8 commits into from
Mar 18, 2022
Merged

Support activestorage #195

merged 8 commits into from
Mar 18, 2022

Conversation

ksss
Copy link
Contributor

@ksss ksss commented Sep 26, 2021

activestorage adds some methods to activerecord model.

@ksss
Copy link
Contributor Author

ksss commented Sep 27, 2021

gem_rbs_collection with symlink is supported on or after 1.7.0.beta.1 ruby/rbs#785 .
But, current rbs_rails's Gemfile is specifying >= 1.6.

Should I wait for the release of rbs v1.7.0 for this PR?

sigs = []

# Needs to require "active_storage/engine"
if klass.respond_to?(:attachment_reflections)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

attachment_reflections will be defined after "active_storage/engine" is required, and will not be defined if it is not required.

https://github.com/rails/rails/blob/3be6c2d67c0dcbefa1c252943b0188b384403ec1/activestorage/lib/active_storage/reflection.rb#L43


# Needs to require "active_storage/engine"
if klass.respond_to?(:attachment_reflections)
sigs << "module GeneratedAssociationMethods"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


if klass.respond_to?(:attachment_reflections)
klass.attachment_reflections.each do |name, _reflection|
sigs << "def #{prefix}with_attached_#{name}: () -> #{relation_class_name}"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

def build_avatar_blob: (untyped) -> ActiveStorage::Blob
def create_avatar_blob: (untyped) -> ActiveStorage::Blob
def create_avatar_blob!: (untyped) -> ActiveStorage::Blob
def reload_avatar_blob: () -> ActiveStorage::Blob?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ksss ksss force-pushed the activestorage branch 2 times, most recently from 693b0ea to 4f21af3 Compare November 12, 2021 13:28
@ksss
Copy link
Contributor Author

ksss commented Nov 12, 2021

Rebased and use rbs 1.7.0.

But I have not been able to solve the CI problem.

nokogiri-1.12.5-x86_64-linux requires ruby version < 3.1.dev, >= 2.5, which is
incompatible with the current version, ruby 3.1.0p-1

CI seems to be down with the following problems.
sparklemotion/nokogiri#2185

@ksss
Copy link
Contributor Author

ksss commented Nov 12, 2021

I resolved CI problem!
I simply avoided using the precompiled gem in the head.

@ksss ksss mentioned this pull request Dec 8, 2021
@pocke pocke self-assigned this Mar 18, 2022
Copy link
Owner

@pocke pocke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! 🚀

@pocke
Copy link
Owner

pocke commented Mar 18, 2022

I've reverted some commits because they are no longer needed on the master branch. And I've merged master into this PR to check it runs on master branch.

@pocke pocke merged commit 24e3ef8 into pocke:master Mar 18, 2022
@ksss
Copy link
Contributor Author

ksss commented Mar 18, 2022

Thank you so much ✨

@ksss ksss deleted the activestorage branch March 18, 2022 05:29
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.

None yet

2 participants