---
title:
  "Rails 7.1 allows audio_tag and video_tag to receive Active Storage
  attachments"
description:
  "Rails 7.1 allows audio_tag and video_tag to receive Active Storage
  attachments"
canonical_url: "https://www.bigbinary.com/blog/rails-7-extends-support-for-audio-tag-and-video-tag"
markdown_url: "https://www.bigbinary.com/blog/rails-7-extends-support-for-audio-tag-and-video-tag.md"
---

# Rails 7.1 allows audio_tag and video_tag to receive Active Storage attachments

Rails 7.1 allows audio_tag and video_tag to receive Active Storage attachments

- Author: Ghouse Mohamed
- Published: July 27, 2022
- Categories: Rails, Rails 7

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.

### Before

```ruby
audio_tag(polymorphic_path(user.audio_file))
# => <audio src="/..."></audio>
video_tag(polymorphic_path(user.video_file))
# => <video src="/..."></video>
```

### After

```ruby
audio_tag(user.audio_file)
# => <audio src="/..."></audio>
video_tag(user.video_file)
# => <video src="/..."></video>
```

Please check out this [pull request](https://github.com/rails/rails/pull/44085)
for more details.

## Links

- [Human page](https://www.bigbinary.com/blog/rails-7-extends-support-for-audio-tag-and-video-tag)
