This project is archived and is in readonly mode.

#1091 ✓resolved
Jan De Poorter

Fix that ActiveRecord would load a whole association when calling first

Reported by Jan De Poorter | September 22nd, 2008 @ 05:01 PM | in 2.x

In some cases AssociationCollection would load the entire association, when just calling first or last. Example:


u = User.find(params[:id])

u.activities.last # Does a find(:last)

# Add something to the activities
u.activities.create!({:description => "List activities"})

u.activities.last # Fetches all activities of the user - Painfull when a user has 30000 activities

The patch included only does a full association load if there are records in the association that aren't saved.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

People watching this ticket

Referenced by

Pages