Ask A Question

Notifications

You’re not receiving notifications from this thread.

How do I upload images using (Administrate Gem + ActiveStorage + Rails 6)

Fahad asked in Rails

Hey Everyone I'm working on rails 6 and building an admin panel using Administrate Gem. I have a product model "has_many_attached :images"
but administrate does not recognizing:
images_attachments: Field::HasMany.with_options(class_name: "ActiveStorage::Attachment"),
images_blobs: Field::HasMany.with_options(class_name: "ActiveStorage::Blob"),
And Showing me text filed instead of file upload.
And I have also tried administrate-field-active_storage gem but when I tried to upload image, after everything i followed mention in Gem's doc, Now It's giving me this error:
undefined method `each' for #ActionDispatch::Http::UploadedFile:0x00007fa17c5af9e0

please advise me any direction.

Reply

Hey Fahad,

Try using this gem to add ActiveStorage support instead: https://github.com/Dreamersoul/administrate-field-active_storage

Reply

Hey, Fahad. I was wondering if you figure this issue out? I am currently trying to do the same but I'm getting the following error after using https://github.com/Dreamersoul/administrate-field-active_storage:

undefined method `attachment' for #Foo:0x00007fb9408234c0

Any idea on how to proceed? thanks.

Reply
Join the discussion
Create an account Log in

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

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

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