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 CarrierWave 3.x #215

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Support CarrierWave 3.x #215

wants to merge 5 commits into from

Conversation

mshibuya
Copy link
Member

This PR aims to make carrierwave-mongoid to work with CarrierWave 3.x, while keeping the support for older CarrierWave versions. Changes are separeted into several commits, to describe the intention better.

- Add spec/tmp to .gitignore
- Fix warning 'Invalid update document provided'
- Set files before testing behavior of #remove_uploaders= and #remove_uploader
- Make sure to reset value of #remove_previously_stored_files_after_update
As CarrierWave 3.0 introduced filename deduplication, it will prevent mistakenly removing the newly-uploaded file in a different way.
if Gem::Version.new(CarrierWave::VERSION) >= Gem::Version.new("3.0.beta")
include CarrierWave3
else
include CarrierWavePre3
end
Copy link
Member Author

Choose a reason for hiding this comment

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

Changes in this file can be better understood by using ?w=1.

What I did was introducing new modules CarrierWave3 and CarrierWavePre3, and conditionally include one of them based on the CarrierWave version.

end
end
}
end
Copy link
Member Author

Choose a reason for hiding this comment

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

carrierwave-mongoid was heavily affected by the issue in carrierwave: carrierwaveuploader/carrierwave#2770. The issue is hard to investigate due to its nature, and affected many carrierwave versions (from 3.0.0 to 3.1.0). Hence I've added a monkey patch here, to ensure carrierwave-mongoid works with flawed carrierwave versions.

@mshibuya mshibuya marked this pull request as ready for review January 13, 2025 05:23
@mshibuya mshibuya requested a review from rmm5t January 13, 2025 05:23
@mshibuya
Copy link
Member Author

@rmm5t Hi! Any chance you can take a look at this? 🙏

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