From 4ecc5d37609c3de8d3b013a738f3704f1e70c61a Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sun, 22 Oct 2023 00:06:48 -0400 Subject: Audio quotes! --- app/controllers/admin/quotes_controller.rb | 2 +- app/models/quote.rb | 2 ++ app/views/admin/quotes/_form.html.haml | 5 +++++ app/views/quotes/_quote.html.haml | 2 ++ 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/controllers/admin/quotes_controller.rb b/app/controllers/admin/quotes_controller.rb index 70a541f..3623463 100644 --- a/app/controllers/admin/quotes_controller.rb +++ b/app/controllers/admin/quotes_controller.rb @@ -49,6 +49,6 @@ class Admin::QuotesController < Admin::AdminController end def quote_params - params.require(:quote).permit(:content, :state, :notes, :submitter, :tag_list) + params.require(:quote).permit(:content, :state, :notes, :submitter, :tag_list, :audio) end end diff --git a/app/models/quote.rb b/app/models/quote.rb index d037aab..518d53b 100644 --- a/app/models/quote.rb +++ b/app/models/quote.rb @@ -5,6 +5,8 @@ class Quote < ApplicationRecord acts_as_taggable + has_one_attached :audio + validates :content, presence: true enumerize :state, diff --git a/app/views/admin/quotes/_form.html.haml b/app/views/admin/quotes/_form.html.haml index 920835b..13948ca 100644 --- a/app/views/admin/quotes/_form.html.haml +++ b/app/views/admin/quotes/_form.html.haml @@ -24,4 +24,9 @@ .published-field = f.label :state = f.select :state, Quote.state.options + .details-module.image-uploads + %h4 Audio + - if f.object.audio.attached? + = audio_tag(rails_blob_url(f.object.audio), controls: true) + = f.file_field :audio .details-module= f.submit diff --git a/app/views/quotes/_quote.html.haml b/app/views/quotes/_quote.html.haml index 46b0266..db6ab8b 100644 --- a/app/views/quotes/_quote.html.haml +++ b/app/views/quotes/_quote.html.haml @@ -7,6 +7,8 @@ %datetime= quote.published_date - if user_signed_in? and !quote.new_record? = link_to "Edit", edit_admin_quote_path(quote), :class => "quote-edit-link" + - if quote.audio.attached? + .audioplayer= audio_tag(rails_blob_url(quote.audio), controls: true) %blockquote.quote-body= raw quote_format(h(quote.content)) - if !quote.new_record? and quote.has_extra? .quote-footer -- cgit 1.4.1