This change moves all serializers into the same namespace (Api::V1) as the controllers which consume those serializers. In doing so it fixes a bug which currently breaks almost any operation in staging, most notably user signup, by falling back to Object#as_json to serialize all API responses, not complying at all with our API spec.
The reason is that while in both Ruby versions, the constant name that we try to look up is namespaced (This namespacing behaviour is documented in later releases, but the behaviour is similar in v0.9.x.):
It is considered appropriate to namespace the serializers together with the consuming controllers because together they constitute a cohesive definition of an API version; should an API V2 be introduced, it should likely have distinct serializers.
This change moves all serializers into the same namespace (
Api::V1
) as the controllers which consume those serializers. In doing so it fixes a bug which currently breaks almost any operation in staging, most notably user signup, by falling back toObject#as_json
to serialize all API responses, not complying at all with our API spec.active_model_serializers
looks for the serializers in this namespace by default, but this worked on Ruby 2.6.5:Since Ruby 2.6.6, a change to constant lookup was introduced which means that the appropriate class can't be found:
The reason is that while in both Ruby versions, the constant name that we try to look up is namespaced (This namespacing behaviour is documented in later releases, but the behaviour is similar in v0.9.x.):
this name is passed to Object#const_get which behaves more strictly since Ruby 2.6.6:
Ruby 2.6.5:
Ruby 2.6.6:
It is considered appropriate to namespace the serializers together with the consuming controllers because together they constitute a cohesive definition of an API version; should an API V2 be introduced, it should likely have distinct serializers.
Interesting source material:
Bug was introduced in #470