ActiveStorage provides an easier way to upload
and
store the files on various cloud services.
Rails also provides easy way to embed them using the appropriate tags.
For example,
image_tag
audio_tag
video_tag
In this article we will see how to embed the ActiveStorage files
and
what’s changed in the latest update.
Let’s take an example of a Movie model.
Our Movie model has various attributes title, duration, etc.
The model also has several attachments poster, title_song and trailer
Before
Before 7.1,
we could pass activestorage attachment to the image_tag while embedding
the image.
Whereas, the same for audio_tag and video_tag was not possible.
The only way to embed the activestorage attachment with audio_tag
and
video_tag was: