Show answers with attachments in additional info
We weren't showing the details of answers without a description, even if they had images, videos or documents. Some users found that behavior unexpected since the description isn't a mandatory field and so they left it blank, but they added images to that answer and they didn't appear on the poll page. Note we had a condition not to show the title of an answer when it had no description. I think that condition was redundant because answers without a description weren't loaded in the first place. Anyway, that condition doesn't make sense anymore because we're displaying answers with images but no description.
This commit is contained in:
@@ -14,6 +14,14 @@ class Poll::Question::Answer < ApplicationRecord
|
||||
validates_translation :title, presence: true
|
||||
validates :given_order, presence: true, uniqueness: { scope: :question_id }
|
||||
|
||||
scope :with_content, -> { where.not(id: without_content) }
|
||||
scope :without_content, -> do
|
||||
where(description: "")
|
||||
.left_joins(:images).where(images: { id: nil })
|
||||
.left_joins(:documents).where(documents: { id: nil })
|
||||
.left_joins(:videos).where(poll_question_answer_videos: { id: nil })
|
||||
end
|
||||
|
||||
def self.order_answers(ordered_array)
|
||||
ordered_array.each_with_index do |answer_id, order|
|
||||
find(answer_id).update_column(:given_order, (order + 1))
|
||||
|
||||
Reference in New Issue
Block a user