Skip to content

respect config.default_includes in #serializable_hash #1762

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

Conversation

y-yagi
Copy link
Contributor

@y-yagi y-yagi commented Jun 1, 2016

Purpose

default_includes config was added in #1426.
However, it has not been used in #serializable_hash, want to use it even #serializable_hash.

Changes

Use config.default_includes to default value of #serializable_hash.

@@ -151,7 +151,7 @@ def success?
# serializer.as_json(include: { posts: { include: { comments: { only: :body } }, only: :title } })
def serializable_hash(adapter_opts = nil)
adapter_opts ||= {}
adapter_opts = { include: '*', adapter: :attributes }.merge!(adapter_opts)
adapter_opts = { include: config.default_includes, adapter: :attributes }.merge!(adapter_opts)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good call. would you mind adding a Changelog entry?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but should be ActiveModelSerializer.default_includes, not config.default_includes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean ActiveModelSerializers.config.default_includes? ActiveModelSerializers module does not have default_includes method, it is an error to ActiveModelSerializers.default_includes.

@bf4
Copy link
Member

bf4 commented Jun 6, 2016

I merged some big refactoring in this area recently. Take a look and let me know how I can help with this PR.

@y-yagi
Copy link
Contributor Author

y-yagi commented Jun 6, 2016

Thank you for pointing out!
After confirming master, it seems already to use config.default_includes in #serializable_hash.
(I think that it's capable of influence of #1766.)
Therefore, I will close this PR. Thanks!

@y-yagi y-yagi closed this Jun 6, 2016
@y-yagi y-yagi deleted the respect_default_includes_in_serializable_hash branch June 12, 2016 23:42
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.

2 participants