kreeti / kt-paperclip

Easy file attachment management for ActiveRecord
Other
275 stars 95 forks source link

Minitest::UnexpectedError: TypeError: no implicit conversion from nil to integer #127

Closed przbadu closed 10 months ago

przbadu commented 11 months ago

Describe the bug

Model code

validates_attachment :logo, content_type: { content_type: %w[image/jpg image/jpeg image/gif image/png] }
  validates_attachment_size :logo, less_than: 5.megabytes, message: 'Max allowed attachment size is 5MB'
  validates_attachment_presence :logo

Test case:

FactoryGirl.create(:payment_provider, logo: File.new('test/fixtures/ofx-logo.png'))

To Reproduce Steps to reproduce the behavior:

  1. I am upgrading my legacy Rails app which was originally built with Rails 4.2 to Rails 5.2.8
  2. We migrated our paperclip to kt-paperclip during rails 5 upgrade and been running it for years without any issue. It worked well till Rails 5.1.x.
  3. As soon as I upgraded Rails version to 5.2.8 I am getting given error Minitest::UnexpectedError: TypeError: no implicit conversion from nil to integer

Expected behavior It should create uploads

Screenshots If applicable, add screenshots to help explain your problem.

image

Desktop (please complete the following information):

Smartphone (please complete the following information):

przbadu commented 10 months ago

So the problem was because of net-protocol gem not actually directly related with paperclip.

The fix was to downgrade net-protocol from 0.2.2 to 0.1.1.

gem 'net-protocol', '~> 0.1.0'

Also note that, it is happening on ruby version 3.0.x and rails version 6.1.x combination.