You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey guys when using the include param for including an association in the response along with some specific fields, with the current implementation I think it is a bit buggy and it doesn't parse the response in the intended way. I've posted a PR where the spec for that feature is more precise, and that spec fails.
The reason behind this is using as_json on the strong params of :include option in the json render which will transform the strong params object into a Hash object with all its keys deeply converted into strings.
Because of that, since we are using as_json on the Model and we have a Hash with keys as strings under the :include key, regardless of the version of rails it will include the associated model with all of its attributes. https://github.com/rails/rails/blob/master/activemodel/lib/active_model/serializers/json.rb#L89-L102 https://github.com/rails/rails/blob/master/activemodel/lib/active_model/serialization.rb#L130
The text was updated successfully, but these errors were encountered:
Hey guys when using the
include
param for including an association in the response along with some specific fields, with the current implementation I think it is a bit buggy and it doesn't parse the response in the intended way. I've posted a PR where the spec for that feature is more precise, and that spec fails.The reason behind this is using
as_json
on thestrong params of :include option
in the json render which will transform the strong params object into a Hash object with all its keys deeply converted into strings.Because of that, since we are using
as_json
on the Model and we have a Hash with keys as strings under the:include
key, regardless of the version of rails it will include the associated model with all of its attributes.https://github.com/rails/rails/blob/master/activemodel/lib/active_model/serializers/json.rb#L89-L102
https://github.com/rails/rails/blob/master/activemodel/lib/active_model/serialization.rb#L130
The text was updated successfully, but these errors were encountered: