-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Consider evaluating association in serializer context #1378
Conversation
This is a must IMO. The current behavior is confusing. |
019b386
to
c9c7666
Compare
We should merge this. How should we go about warning people migrating from previous versions? |
Changelog? Update doc? B mobile phone
|
For discussion: Consider evaluating association in serializer context That way, associations are really just anything that can be conditionally included. They no longer have to actually be methods on the object or serializer. e.g. ```diff has_many :comments do - last(1) + Comment.active.for_serialization(object).last(1) end ```
c9c7666
to
d7de53c
Compare
* Syntax changes from e.g. | ||
`has_many :titles do customers.pluck(:title) end` (in #1356) to | ||
`has_many :titles do object.customers.pluck(:title) end` | ||
- [#1356](https://github.com/rails-api/active_model_serializers/pull/1356) Add inline syntax for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this belong here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why wouldn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh... They're just missing from changelog. How would you prefer i include them?
B mobile phone
On Dec 31, 2015, at 12:05 PM, Lucas Hosseini notifications@github.com wrote:
In CHANGELOG.md:
@@ -16,7 +16,22 @@ Breaking changes:
Features:
-- #1336 Added support for Grape >= 0.13, < 1.0
+- #1378 Change association blocks
- to be evaluated in serializer scope, rather than association scope. (@bf4)
- * Syntax changes from e.g.
`has_many :titles do customers.pluck(:title) end` (in #1356) to
+- #1356 Add inline syntax for`has_many :titles do object.customers.pluck(:title) end`
Because this PR is Consider evaluating association in serializer context #1378 and not Add inline syntax for attributes and associations #1356—
Reply to this email directly or view it on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added it to my local master and merged locally so it's two commits, but not part of this PR merge commit
For discussion:
Consider evaluating association in serializer context
That way, associations are really just anything that
can be conditionally included. They no longer
have to actually be methods on the object or serializer.
e.g.
ref: #1356