active_storage_validations icon indicating copy to clipboard operation
active_storage_validations copied to clipboard

Dimension validator not working

Open vitobotta opened this issue 3 years ago • 5 comments

Hi! I am having a problem with the dimension validator where this line causes the exception NoMethodError (undefined method id' for nil:NilClass)`.

Any idea of how to fix? Thanks!

ps. I'm on Rails master if that's relevant.

vitobotta avatar Sep 20 '20 13:09 vitobotta

Adding that I am doing direct upload to S3.

vitobotta avatar Sep 20 '20 13:09 vitobotta

I debugged the code and it passes in a string that is super long (eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBGZz09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--0d6f6469d9e6acf521c4bb6aeb460a4997419115), and causes an issue on line 24 of Metadata.rb, where ActiveStorage::Blob.find_signed(file) returns nil.

Not sure how to proceed, as it seems like this is an ActiveRecord issue, and I'm not really sure how to solve it!

mmotherwell avatar Dec 27 '20 09:12 mmotherwell

Sorry to double post, on a whim I changed the code on Metadata.rb on 24 to add the ! (as In could not find a method ActiveStorage::Blob.find_signed without the bang) and it works, e.g. change

blob = is_string ? ActiveStorage::Blob.find_signed(file) : file

to

blob = is_string ? ActiveStorage::Blob.find_signed!(file) : file

mmotherwell avatar Dec 27 '20 09:12 mmotherwell

@mmotherwell please prepare a PR with a fix. And I'll merge it

igorkasyanchuk avatar Dec 28 '20 20:12 igorkasyanchuk

Is it not in master? Should I just get the tests passing?

consitently avatar Dec 30 '20 10:12 consitently

Hi everyone, I think this issue has been solved by https://github.com/igorkasyanchuk/active_storage_validations/commit/b84dfeaba49d948ad15822a582286577a96cfa61 in December 2020. @mmotherwell, @consitently, @vitobotta let me know if that's not the case, otherwise I'll close this issue by week's end considering it's been solved in order to clean up the gem backlog.

Mth0158 avatar Nov 21 '23 11:11 Mth0158