The existing code assumes that if you have a fields ending with _attributes, that it's a collection. This isn't neccessarily true. You can have a nested one-to-one relationship, where x_attributes is just a object, rather than a collection.
These changes account for that fact.
Specifically, line 60 checks if the association can be iterated over, otherwise process it as a resource.
Line 76 handles ancestry only having 2 elements. Previous if Foo belongs to Bar, then the ancestory would be ['foo', 'bar']. This would create a resource name of foo_bar_attributes_, which has a trailing underscore.
The existing code assumes that if you have a fields ending with
_attributes
, that it's a collection. This isn't neccessarily true. You can have a nested one-to-one relationship, wherex_attributes
is just a object, rather than a collection.These changes account for that fact.
Specifically, line 60 checks if the association can be iterated over, otherwise process it as a resource.
Line 76 handles ancestry only having 2 elements. Previous if Foo belongs to Bar, then the ancestory would be
['foo', 'bar']
. This would create a resource name offoo_bar_attributes_
, which has a trailing underscore.