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

`pluck` disregards preloaded data #28747

toby-1-kenobi opened this Issue Apr 13, 2017 · 1 comment


None yet
3 participants

toby-1-kenobi commented Apr 13, 2017

Steps to reproduce

In the controller:
@users = User.includes(:posts)

In the view:
@users.each{ |user| user.posts.pluck(:title) }

Expected behaviour

pluck shouldn't issue a database query to get the post title since posts have been preloaded by includes. It should behave in the same way as
@users.each{ |user| }

Actual behaviour

pluck issues a new query for each user retrieving posts

System configuration

Rails version: 4.2.6

Ruby version: 2.3.0p0


This comment has been minimized.

Show comment
Hide comment

kamipo Apr 13, 2017


Fixed in #25976.


kamipo commented Apr 13, 2017

Fixed in #25976.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment