All threads / How can I get a file object from active storage to attach to a different model?
Ask A Question

Notifications

You’re not receiving notifications from this thread.

How can I get a file object from active storage to attach to a different model?

Brian Carpenter asked in Rails

I'd like to access a file object that already exists in active storage and re-attach it to another model. Something like
@newmodel.image.attach(file_object_already_in_active_storage)

Is this possible?

Variations of rails_blob_path and url_for methods produce invalid signature errors.

Found this link on how to reference a blob for use with another model.

https://github.com/rails/rails/issues/31674

Join the discussion

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

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

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

    logo Created with Sketch.

    Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more. Icons by Icons8

    © 2022 GoRails, LLC. All rights reserved.