Fix infinite recursion

The method for testing whether to include an association was causing
an infinite loop when two models referenced each other.
This commit is contained in:
Gary Gordon
2014-11-07 09:28:10 -05:00
parent 95d122046d
commit d97b2f5005
9 changed files with 54 additions and 13 deletions

View File

@@ -38,6 +38,7 @@ end
Post = Class.new(Model)
Comment = Class.new(Model)
Author = Class.new(Model)
Bio = Class.new(Model)
Blog = Class.new(Model)
PostSerializer = Class.new(ActiveModel::Serializer) do
@@ -59,6 +60,13 @@ AuthorSerializer = Class.new(ActiveModel::Serializer) do
attributes :id, :name
has_many :posts, embed: :ids
belongs_to :bio
end
BioSerializer = Class.new(ActiveModel::Serializer) do
attributes :id, :content
belongs_to :author
end
BlogSerializer = Class.new(ActiveModel::Serializer) do