rootstrap / active-storage-base64

Base64 support for ActiveStorage
https://rootstrap.com
MIT License
161 stars 16 forks source link

Transforming Images #47

Closed mhmdAljefri closed 4 years ago

mhmdAljefri commented 4 years ago

I want to enable variants, like Rails Active Storage. Transforming Images Guide

I tried to add the processing image gem image_processing, then use variant method:

Model.avatar.variant(resize_to_limit: [100, 100])

expected behavior:

resized image

Current behavior:

rescue in method_missing
Caused by NoMethodError: undefined method 'variant' for #<ActiveStorageSupport::Base64One:0x0000000002d22510>

Any help to implement this with ability of use base64 files

santib commented 4 years ago

It is working for me image

Versions: ruby 2.6.5 rails 6.0.1 active_storage_base64 1.0.0

would you mind providing your versions?

mhmdAljefri commented 4 years ago

Versions:

ruby 2.6.0p0, rails (5.2.3), active_storage_base64 (0.1.4) @santib :)

I think It's from rails version?

santib commented 4 years ago

@mhmdAljefri Seems like it wasn't a problem with the versions. I was able to reproduce it by calling variant to an empty attachment.

I don't think this is a bug introduced by the gem, I see the same error with has_one_attached. Example:

class User
  has_one_base64_attached :avatar
  has_one_attached :image
end

image

So I think you'll solve this issue by doing Model.avatar.variant(resize_to_limit: [100, 100]) if Model.avatar.attached?