ruby-on-rails 将音频播放器添加到活动管理面板

ekqde3dh  于 4个月前  发布在  Ruby
关注(0)|答案(1)|浏览(52)

我有一个博客,接受与Rails 6附带的音频文件的意见。
是否可以在活动的管理员 Jmeter 板中显示音频并收听它们?
我有

#/models/comment.rb
class Comment < ApplicationRecord
  belongs_to :post
  belongs_to :user

  has_one_attached :audio_file
end

个字符
我试着把

index do
    selectable_column
    id_column
    column :audio_file
    column :challenge_id
    column :created_at
    column :deleted_by
    actions
  end


但它只是添加文本audio_file
如何添加audio_tagaudio_file连接?

s6fujrry

s6fujrry1#

使用audio_tag helper method如下:

index do
  selectable_column
  id_column
  column :audio_file do |comment|
    if comment.audio_file.attached?
      audio_tag(comment.audio_file, autoplay: false, controls: true)
    else
      # Do whatever needed
    end
  end
  column :challenge_id
  column :created_at
  column :deleted_by
  actions
end

字符串
audio_tag支持原生audio Embed Audio元素属性。

相关问题