Ask A Question

Notifications

You’re not receiving notifications from this thread.

Active Storage replace attached from a variant

Alejandro Sierra asked in Rails

Following the example from the guide, I can create a variant as soon as I upload an image, but I want the main image, the attached blob to be that variant. How can I do it in an easy and clean way?

Reply

Just re-assign it to the variant?

record.update(image: record.image.variant(...))
Reply

I tried to do that in an before_save :default_values in the line:
self.update(image: self.image.variant(:thumb))
and I got this error message:

Could not find or build blob: expected attachable, got #true}, service_name: "local", byte_size: 213394, checksum: "kz1jimxJihCUHf7Ma+DLpw==", created_at: nil>, @variation=#"jpg", :resize_to_limit=>[200, 200]}>>

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 86,946+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.