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

Version names starting with underscore and numbers lead to NameError #2722

Closed
langalex opened this issue Jan 30, 2024 · 0 comments · Fixed by #2748
Closed

Version names starting with underscore and numbers lead to NameError #2722

langalex opened this issue Jan 30, 2024 · 0 comments · Fixed by #2748
Labels

Comments

@langalex
Copy link

Given an uploader:

class MyUploader < CarrierWave::Uploader::Base
  version :_800x600 do
    process resize_to_fill: [800, 600]
  end
end

leads to this error:

NameError:
  wrong constant name 800x600VersionUploader

# [..]/carrierwave-3.0.5/lib/carrierwave/uploader/versions.rb:23:in `const_set'
# [..]/carrierwave-3.0.5/lib/carrierwave/uploader/versions.rb:23:in `build'
# [..]/carrierwave-3.0.5/lib/carrierwave/uploader/versions.rb:176:in `block in versions'
# [..]/carrierwave-3.0.5/lib/carrierwave/uploader/versions.rb:175:in `each'
# [..]/carrierwave-3.0.5/lib/carrierwave/uploader/versions.rb:175:in `versions'
# [..]/carrierwave-3.0.5/lib/carrierwave/uploader/versions.rb:301:in `active_versions'
# [..]/carrierwave-3.0.5/lib/carrierwave/uploader/versions.rb:309:in `derived_versions'
# [..]/carrierwave-3.0.5/lib/carrierwave/uploader/versions.rb:329:in `cache_versions!'
# [..]/carrierwave-3.0.5/lib/carrierwave/uploader/callbacks.rb:16:in `block in with_callbacks'
# [..]/carrierwave-3.0.5/lib/carrierwave/uploader/callbacks.rb:16:in `each'
# [..]/carrierwave-3.0.5/lib/carrierwave/uploader/callbacks.rb:16:in `with_callbacks'
# [..]/carrierwave-3.0.5/lib/carrierwave/uploader/cache.rb:146:in `cache!'
# [..]/carrierwave-3.0.5/lib/carrierwave/uploader/versions.rb:234:in `cache!'
# [..]/carrierwave-3.0.5/lib/carrierwave/uploader/store.rb:80:in `store!'

A possible solution could be to prefix the generated class name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants