Skip to content
This repository was archived by the owner on Jul 13, 2023. It is now read-only.
This repository was archived by the owner on Jul 13, 2023. It is now read-only.

With Ruby 3.0 validator produces "ArgumentError: wrong number of arguments (given 3, expected 1..2)" #2673

Description

@vtamara

The regression tests of an open source rails engine called sip, that uses paperclip, work good with Ruby 2.7 as can be seen at:
https://travis-ci.org/github/pasosdeJesus/sip/jobs/760216853

However with Ruby 3.0 the following errors appear (as can be seen at https://travis-ci.org/github/pasosdeJesus/sip/jobs/760216854#L976):

1) Error:

Sip::AnexoTest#test_no_valido_1:

ArgumentError: wrong number of arguments (given 3, expected 1..2)

    /home/travis/build/pasosdeJesus/sip/vendor/bundle/ruby/3.0.0/gems/activemodel-6.1.3/lib/active_model/errors.rb:404:in `add'

    /home/travis/build/pasosdeJesus/sip/vendor/bundle/ruby/3.0.0/gems/paperclip-6.1.0/lib/paperclip/validators/attachment_presence_validator.rb:8:in `validate_each'
...

and

2) Error:

Sip::AnexoTest#test_no_valido_2:

ArgumentError: wrong number of arguments (given 3, expected 1..2)

    /home/travis/build/pasosdeJesus/sip/vendor/bundle/ruby/3.0.0/gems/activemodel-6.1.3/lib/active_model/errors.rb:404:in `add'

    /home/travis/build/pasosdeJesus/sip/vendor/bundle/ruby/3.0.0/gems/paperclip-6.1.0/lib/paperclip/validators/attachment_presence_validator.rb:8:in `validate_each'
...

Both are related to expressions anexo.valid? where anexo is amodel with a paperclip attachment. Both use the validator AttachmetntPresenceValidator that includes the statement producing the error:

def validate_each(record, attribute, value)
    if record.send("#{attribute}_file_name").blank?
      record.errors.add(attribute, :blank, *options)
    end
end  

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions