-
Notifications
You must be signed in to change notification settings - Fork 526
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
model.assocations.decorate loads the association even if it is preloaded (AR) #827
Comments
@codebycliff I don't think there is any way to avoid this query when |
@brunohkbx, thanks for the point 👍 |
Alexander-Senko
added a commit
to Alexander-Senko/draper
that referenced
this issue
Sep 4, 2024
`ActiveRecord::Associations::CollectionProxy#decorate` ignores `target` (be it already loaded or not) and loads the association again every time it's called. That's why unsaved records get missing from the decorated collection. Resolves drapergem#646, drapergem#706, drapergem#827.
1 task
Alexander-Senko
added a commit
to Alexander-Senko/draper
that referenced
this issue
Sep 4, 2024
`ActiveRecord::Associations::CollectionProxy#decorate` ignores `target` (be it already loaded or not) and loads the association again every time it's called. That's why unsaved records get missing from the decorated collection. Resolves drapergem#646, drapergem#706, drapergem#827.
Alexander-Senko
added a commit
to Alexander-Senko/draper
that referenced
this issue
Sep 4, 2024
`ActiveRecord::Associations::CollectionProxy#decorate` ignores `target` (be it already loaded or not) and loads the association again every time it's called. That's why unsaved records get missing from the decorated collection. Resolves drapergem#646, drapergem#706, drapergem#827.
Alexander-Senko
added a commit
to Alexander-Senko/draper
that referenced
this issue
Sep 4, 2024
`ActiveRecord::Associations::CollectionProxy#decorate` ignores `target` (be it already loaded or not) and loads the association again every time it's called. That's why unsaved records get missing from the decorated collection. Resolves drapergem#646, drapergem#706, drapergem#827.
1 task
Alexander-Senko
added a commit
to Alexander-Senko/draper
that referenced
this issue
Sep 4, 2024
`ActiveRecord::Associations::CollectionProxy#decorate` ignores `target` (be it already loaded or not) and loads the association again every time it's called. That's why unsaved records get missing from the decorated collection. Resolves drapergem#646, drapergem#706, drapergem#827.
Alexander-Senko
added a commit
to Alexander-Senko/draper
that referenced
this issue
Sep 7, 2024
`ActiveRecord::Associations::CollectionProxy#decorate` ignores `target` (be it already loaded or not) and loads the association again every time it's called. That's why unsaved records get missing from the decorated collection. Resolves drapergem#646, drapergem#706, drapergem#827.
Alexander-Senko
added a commit
to Alexander-Senko/draper
that referenced
this issue
Sep 7, 2024
`ActiveRecord::Associations::CollectionProxy#decorate` ignores `target` (be it already loaded or not) and loads the association again every time it's called. That's why unsaved records get missing from the decorated collection. Resolves drapergem#646, drapergem#706, drapergem#827.
Alexander-Senko
added a commit
to Alexander-Senko/draper
that referenced
this issue
Sep 7, 2024
`ActiveRecord::Associations::CollectionProxy#decorate` ignores `target` (be it already loaded or not) and loads the association again every time it's called. That's why unsaved records get missing from the decorated collection. Resolves drapergem#646, drapergem#706, drapergem#827.
Alexander-Senko
added a commit
to Alexander-Senko/draper
that referenced
this issue
Sep 7, 2024
`ActiveRecord::Associations::CollectionProxy#decorate` ignores `target` (be it already loaded or not) and loads the association again every time it's called. That's why unsaved records get missing from the decorated collection. Resolves drapergem#646, drapergem#706, drapergem#827.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi there,
first and foremost - thanks for draper 🎉
In our application I run into the problem that I want to explicitly decorate an association not as part of the decorator definition (sadly this easily leads to performance problems) so we want to do
model.association.decorate
but this seems to reload the objects from the database even if they were preloaded before.See this snippet:
Draper version in use is 3,0.0.
Somewhat related issues (associations and preloading) are:
edit: FYI mapping over all objects and decorating them instead seems to be a fine workaround as indicated by early testing
ts.tour_schedule_plans.map &:decorate
Thanks!
The text was updated successfully, but these errors were encountered: