Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed a bug that appears when a nil association is included #868

Merged
merged 1 commit into from
Apr 19, 2015

Conversation

groyoh
Copy link
Member

@groyoh groyoh commented Apr 3, 2015

Take a serializer that has an association with a serializer specified for this association, e.g.:

PostPreviewSerializer = Class.new(ActiveModel::Serializer) do
  attributes :title, :body, :id
  belongs_to :author, serializer: AuthorPreviewSerializer
end

When serialized with JsonApi adapter, if this association is included and the value associated is nil then included would look like this: "included":[{"id":"", type:"nil_classes"}].

I changed the behaviour so that it only non nil values are added to included.

kurko added a commit that referenced this pull request Apr 19, 2015
Fixed a bug that appears when a nil association is included
@kurko kurko merged commit 820db0b into rails-api:master Apr 19, 2015
@kurko
Copy link
Member

kurko commented Apr 19, 2015

Thanks @groyoh!

@groyoh groyoh deleted the bug-with-nil-association branch April 27, 2015 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants