Rails 7.1 allows audio_tag and video_tag to receive Active Storage attachments

Ghouse Mohamed

By Ghouse Mohamed

on July 27, 2022

This blog is part of our  Rails 7 series.

Rails 7.1 allows audio_tag and video_tag ActionView helpers to receive Active Storage Attachments which implicitly unpacks the asset path to be included in the src attribute of the <audio></audio> and <video></video> tags.

Previously, the helper methods received only the asset path/url. To get the asset path of an Active Storage Attachment, we had to explicitly call polymorphic_path on the attachment, which returned the desired asset path.


2# => <audio src="/..."></audio>
4# => <video src="/..."></video>


2# => <audio src="/..."></audio>
4# => <video src="/..."></video>

Please check out this pull request for more details.

Stay up to date with our blogs. Sign up for our newsletter.

We write about Ruby on Rails, ReactJS, React Native, remote work,open source, engineering & design.