This commit is contained in:
邱博亞 2021-11-16 10:14:40 +08:00
parent c7610faff4
commit 8e53925406
2 changed files with 7 additions and 3 deletions

View File

@ -11,8 +11,10 @@ class FaqsController < ApplicationController
end end
qa_files = qa.qa_files.map do |qa_file| qa_files = qa.qa_files.map do |qa_file|
next if !qa_file.enabled_for?(locale) next if !qa_file.enabled_for?(locale)
file = qa_file.file
next if file.path.nil?
{ {
"file_url" => qa_file.file.url + "\" title=\"#{qa_file.file_title}", "file_url" => file.url + "\" title=\"#{qa_file.file_title}",
"file_title" => (qa_file.title.blank? ? File.basename(qa_file["file"]) : qa_file.title) "file_title" => (qa_file.title.blank? ? File.basename(qa_file["file"]) : qa_file.title)
} }
end.compact end.compact
@ -42,8 +44,10 @@ class FaqsController < ApplicationController
faqs_files = faq.qa_files.collect do |f| faqs_files = faq.qa_files.collect do |f|
next if !qa_file.enabled_for?(locale) next if !qa_file.enabled_for?(locale)
file = qa_file.file
next if file.path.nil?
{ {
"file_url" => f.file.url + "\" title=\"#{f.file_title}", "file_url" => file.url + "\" title=\"#{f.file_title}",
"file_title" => f.title "file_title" => f.title
} }
end.compact end.compact

View File

@ -16,7 +16,7 @@ class QaFile
elsif self.title.present? elsif self.title.present?
return self.title return self.title
else else
return File.basename(self.file.path) return (File.basename(self.file.path) rescue nil)
end end
end end
def enabled_for?(lang) def enabled_for?(lang)