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

Work without ActiveStorage #3215

Merged
merged 4 commits into from
Sep 5, 2024
Merged

Conversation

jpawlyn
Copy link
Contributor

@jpawlyn jpawlyn commented Sep 3, 2024

If ActiveStorage is not included in a Rails app, then we see the error uninitialized constant Avo::Fields::Common::Files::ControlsComponent::ActiveStorage

Description

When running with eager_load set to true, when starting puma we are seeing the error:

3.3.3/lib/ruby/gems/3.3.0/gems/avo-3.12.0/app/components/avo/fields/common/files/controls_component.rb:10:in `<class:ControlsComponent>': uninitialized constant Avo::Fields::Common::Files::ControlsComponent::ActiveStorage (NameError)

  prop :file, ActiveStorage::Attachment
              ^^^^^^^^^^^^^

Fixes # (issue)

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works

Screenshots & recording

Manual review steps

  1. Step 1
  2. Step 2

Manual reviewer: please leave a comment with output from the test if that's the case.

if ActiveStorage is not included, then we see the error uninitialized constant Avo::Fields::Common::Files::ControlsComponent::ActiveStorage
Copy link

codeclimate bot commented Sep 3, 2024

Code Climate has analyzed commit d316229 and detected 0 issues on this pull request.

View more on Code Climate.

@adrianthedev adrianthedev added the Bug Something isn't working label Sep 3, 2024
@jpawlyn
Copy link
Contributor Author

jpawlyn commented Sep 3, 2024

Note, we only see this issue with 3.11.8 and above - see v3.11.7...v3.11.8

Copy link
Contributor

@Paul-Bob Paul-Bob left a comment

Choose a reason for hiding this comment

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

Hello @jpawlyn, thanks for this contribution!

In the original approach, if ActiveStorage::Attachment is not defined, the prop :file would also remain undefined.

I applied a suggestion to remove the type from file to ensure the prop exists even if ActiveStorage::Attachment is not defined.

@Paul-Bob Paul-Bob merged commit 3316e4a into avo-hq:main Sep 5, 2024
22 checks passed
@Paul-Bob Paul-Bob added the Fix label Sep 5, 2024
@adrianthedev adrianthedev mentioned this pull request Sep 6, 2024
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Fix
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants