mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Don’t try to serialize associations in PostRevisionSerializer
Currently, if an association is added as a tracked field in `PostRevisor`, the `PostRevisionSerializer` class will try to serialize it somehow. This will raise an error as ActiveRecord collection proxies can't be serialized. This patch addresses this issue by skipping any association tracked by the `PostRevisor` class.
This commit is contained in:
committed by
Loïc Guitaut
parent
3be925e161
commit
5177aef37d
@@ -219,8 +219,13 @@ class PostRevisionSerializer < ApplicationSerializer
|
||||
|
||||
# Retrieve any `tracked_topic_fields`
|
||||
PostRevisor.tracked_topic_fields.each_key do |field|
|
||||
next if field == :tags
|
||||
latest_modifications[field.to_s] = [topic.public_send(field)] if topic.respond_to?(field)
|
||||
next unless topic.respond_to?(field)
|
||||
topic
|
||||
.public_send(field)
|
||||
.then do |value|
|
||||
next if value.try(:proxy_association)
|
||||
latest_modifications[field.to_s] = [value]
|
||||
end
|
||||
end
|
||||
|
||||
latest_modifications["featured_link"] = [
|
||||
|
||||
Reference in New Issue
Block a user