-
-
Notifications
You must be signed in to change notification settings - Fork 94
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
wrong number of arguments (given 3, expected 1..2) with validations on Rails 6.1 #46
Comments
@rmehner If you can please create a PR for this, we can then take it forward. thanks! |
@ssinghi was planning to, but |
@rmehner it is because of all the ruby versions and the needed gems. Takes a long time without proper RVM setup for all required ruby versions. I would recommend creating a PR and let Travis deal with it. Or, my PR just got merged and I can do this for you. |
It's stuck at the |
Hi @ssinghi, would you be able to release a gem with this fix in it? :) |
New gem version v7.0.0 released as well . |
Thanks @ssinghi. Much appreciated :D |
Can confirm this works as expected. Thanks for your work @ssinghi, didn't came around to do it for myself. |
module Paperclip::Validators::MonkeyPatches
def mark_invalid(record, attribute, types)
record.errors.add attribute, :invalid, **options.merge(:types => types.join(', '))
end
end
Paperclip::Validators::AttachmentContentTypeValidator.prepend(Paperclip::Validators::MonkeyPatches)
Paperclip::Validators::AttachmentFileNameValidator.prepend(Paperclip::Validators::MonkeyPatches) if you can't update the gem. This mokeypatch does fix that problem for me. |
Describe the bug
When using kt-paperclip on Rails 6.1, when using validations that will trigger errors, Rails will throw a
wrong number of arguments (given 3, expected 1..2)
error.See rails/rails#41270 for details on that.
To Reproduce
This will trigger the error, if avatar is missing
Expected behavior
Should not trigger the error.
Additional context
Changing https://github.com/kreeti/kt-paperclip/blob/master/lib/paperclip/validators/attachment_presence_validator.rb#L7 to:
Fixes it for the presence validator. Not sure how compatible that would be to older versions though.
The text was updated successfully, but these errors were encountered: