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:

The above will result in:

### After

After Rails 7 extends audio_tag and video_tag to accept Active Storage attachments we don’t need to use polymorphic_path anymore.

Let’s take a look at the same code after this change.

The above will result in: