-
Notifications
You must be signed in to change notification settings - Fork 180
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
FilenameFormatValidator fails for every new object #227
Comments
@pramodshinde I am getting the same issue. This works fine when I upload an image for an existing model... but fails when a new model is created. |
@pramodshinde I am getting the same issue too when I'm creating an upload from a remote location. It can be solved by |
@in-hale but adding record.send("has_#{attribute}_upload?") && record.send("#{attribute}_key") !~ record.send(attribute).key_regexp |
Carrierwave-direct doesn't currently support creating an upload be setting the file on the model. For tests you can use sample_key in https://github.com/dwilkie/carrierwave_direct/blob/32fb37708671f72fb7fc6c1a0c7196e5f8291a2d/lib/carrierwave_direct/test/helpers.rb |
Not sure @p8 What you are suggesting here? Can you elaborate for my use case? |
@pramodshinde It's not, and it's exactly the line where things go wrong. However, I found a better walkaround here:
And then you can set this back to |
I am using carrierwave_direct for direct uploads and server side uploads. For every new object I am getting following error
"avatar: is invalid. "
I dived into gems code found that following condition in failing for each new object as validations are getting invoked on :create and this conditions is always turns to be true.
Here
record.send("#{attribute}_key")
is"public/user/avatar//"
record.send(attribute).key_regexp
is/\A(public\/user\/avatar\/|uploads\/tmp)\/[a-f\d\-]+\/.+\.(?i)\w+(?-i)\z/
I thought
"public/user/avatar//"
invalid and this condition getting true because of this path but when I tried putting valid path like"public/user/avatar/199164/sample.pdf"
!~ `/\A(public/user/avatar/|uploads/tmp)/[a-f\d-]+/.+.(?i)\w+(?-i)\z/``This is also failing, Not sure whats wrong? Is this regex checking wrong or path which I am generating is wrong?
Model:
Carrierwave Config
The text was updated successfully, but these errors were encountered: