Hi all, I found a strange behaviour in eager loading:
class Category < ActiveRecord::Base has_and_belongs_to_many :movies has_and_belongs_to_many :most_recent_movies, :class_name => 'Movie', :order => 'created_at DESC', :limit => 10 end
class Movie < ActiveRecord::Base has_and_belongs_to_many :categories end
Category.find(1).most_recent_movies # => returns 10 movies
Category.find(1, :include => :most_recent_movies).most_recent_movies # => returns all the associated movies
I fixed it, you can find the patch at: http://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/505-eager-loading-doesn-t-respect-limit-option-of-the-loaded-association
Best, Luca