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

Fix: NoMethodError (MAYBE-RAILS-CV) #1659

Closed
wants to merge 1 commit into from

Conversation

revise-dev[bot]
Copy link

@revise-dev revise-dev bot commented Jan 23, 2025

The error occurs because we're trying to call delete_all on ActiveStorage::Variant, which is a processing utility class, rather than ActiveStorage::VariantRecord, which is the ActiveRecord model that actually corresponds to the database table active_storage_variant_records.

From examining the schema.rb file, we can see that Active Storage is properly set up with the active_storage_variant_records table (line 142-146). The original code was attempting to perform bulk deletion using the wrong class.

To fix this, we need to replace any calls to ActiveStorage::Variant.delete_all with ActiveStorage::VariantRecord.delete_all. The VariantRecord class is the proper ActiveRecord model that has access to the delete_all class method through its inheritance from ApplicationRecord.

Based on the existing test conventions shown in test/models/user_test.rb, I'm adding a new test file specifically for testing Active Storage variant record management. The test follows the established patterns of:

  1. Using descriptive test names
  2. Making assertions about expected behavior
  3. Following the setup/exercise/verify pattern

The test will verify that:

  1. Variant records can be deleted without errors
  2. The operation actually removes records from the database

Tip

You can make revisions or ask questions of Revise.dev by using /revise in any comment or review!

  • /revise Add a comment above the method to explain why we're making this change.
  • /revise Why did you choose to make this change specifically?

Important

If something doesn't look right, click to retry this interaction.

@zachgoll zachgoll closed this Jan 24, 2025
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.

1 participant