Fix empty authors preview card serialization (#33151)
This commit is contained in:
parent
6fddf1610c
commit
e5bea68b20
2 changed files with 49 additions and 1 deletions
|
@ -134,7 +134,7 @@ class PreviewCard < ApplicationRecord
|
|||
end
|
||||
|
||||
def authors
|
||||
@authors ||= [PreviewCard::Author.new(self)]
|
||||
@authors ||= Array(serialized_authors)
|
||||
end
|
||||
|
||||
class Author < ActiveModelSerializers::Model
|
||||
|
@ -169,6 +169,13 @@ class PreviewCard < ApplicationRecord
|
|||
|
||||
private
|
||||
|
||||
def serialized_authors
|
||||
if author_name? || author_url?
|
||||
PreviewCard::Author
|
||||
.new(self)
|
||||
end
|
||||
end
|
||||
|
||||
def extract_dimensions
|
||||
file = image.queued_for_write[:original]
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue