Data Seeding: Create fake image data using image URLs #581
-
Hi, during data seeding, I want to create fake
According to the docs, I can build an {
id: "...",
storage: "...",
metadata: {
size: "...",
filename: "...",
mime_type: "..."
}
} However, the problem is there is no way to create the object from image URLs where I can retrieve the stored image using the Thank you. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Having just done something similar, i think what you want is:
For instance, on an ActiveRecord model with an
Let me know if it does what you want? |
Beta Was this translation helpful? Give feedback.
-
Unfortunately, calling
While digging into the source code, I found that I need to instantiate a The full steps are shown below:
You can now retrieve the image by calling |
Beta Was this translation helpful? Give feedback.
Unfortunately, calling
model.image_attacher.set(image_data_hash)
gave me this error:While digging into the source code, I found that I need to instantiate a
Shrine::UploadedFile
object with theimage_data_hash
. Also, I need a gem called shrine-url to create a fake storage that allows me to assign image data by custom URLs.The full steps are shown below:
gem "shrine-url", "~> 2.4"
to your Gemfile.config/initializers/shrine.rb
, add the following lines: