avoid N+1 query even if no custom fields exist
This commit is contained in:
parent
0369f26a39
commit
539ca73668
|
@ -292,8 +292,12 @@ class PostSerializer < BasicPostSerializer
|
|||
end
|
||||
|
||||
def post_custom_fields
|
||||
@post_custom_fields ||= (@topic_view.present? && @topic_view.post_custom_fields.present?) ? @topic_view.post_custom_fields[object.id] : nil
|
||||
@post_custom_fields ||= object.custom_fields
|
||||
@post_custom_fields ||=
|
||||
if @topic_view
|
||||
@topic_view.post_custom_fields && @topic_view.post_custom_fields[object.id]
|
||||
else
|
||||
object.custom_fields
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue