Rails 活动存储:video_tag 不显示视频

Rails Active Storage : video_tag not showing video

我正在尝试使用 Rails 5.2.3 和 Active Storage 在我的应用中实现一些上传然后播放视频。在与活动存储斗争了一段时间后,我终于确定我的附件包含我要附加的文件 => 在检查 src 是正确的之后 这里的问题是我不断从 firefox 控制台收到这些警告:

HTTP "Content-Type" of "text/html" is not supported. Load of media resource http://localhost:3000/rails/active_storage/blobs/eyJfcmFpbHM…JibG9iX2lkIn19--a44730f58a07282f626737b6a541d57fa9dc11c4/vid failed. 23 Cannot play media. No decoders for requested formats: text/html

和带有以下消息的视频区域“
找不到支持格式和 MIME 类型的视频

现在,控制台警告仅出现在 Firefox 中,但视频无法在我测试的所有浏览器中播放,因此我认为我的问题与警告有关。我是 rails 的新手,所以我尝试了在 google 中找到的所有内容,但没有解决我的问题。

我正在用 video_tag 以这种方式显示视频:

 <%= video_tag(url_for(@play.clip), style: "width:100%;height:auto", :controls => true) if @play.clip.attached? %>

并在初始化器中添加了一个meme_types.rb,代码如下

Rack::Mime::MIME_TYPES.merge!({
                                ".mp4" => "video/mp4",
                              })

我尝试使用纯 html5(相同)显示视频,我自然会收到相同的警告...

已修复。问题不是来自活动存储本身。播放视频的获取请求被我在 routes.rb 中写的一行停止,以使所有 "unknown routes" 重定向到 root_path:

get '*path' => redirect('/')

现在视频播放视频已经修复了我要处理"redirecting unknown paths to root without causing a problem with the GET "