carrierwaveuploader / carrierwave

Classier solution for file uploads for Rails, Sinatra and other Ruby web frameworks
https://github.com/carrierwaveuploader/carrierwave
8.78k stars 1.66k forks source link

Fix a `NoMethodError` when a record is rollbacked #2674

Closed y-yagi closed 1 year ago

y-yagi commented 1 year ago

Since v3.0.0, Carrierwave raises NoMethodError when a record is rollbacked if uploaders methods don't call at all.

NoMethodError:
  private method `select' called for nil:NilClass

    current_paths = (@removed_uploaders + @uploaders.select(&:staged)).map(&:path)

This attempts to fix that error and makes work correctly.

mshibuya commented 1 year ago

Great, thank you for the fix!