Thanks to @railscasts I just learned about about ActiveRecord::SpawnMethods::merge – very cool feature.

Register or log in to add new notes. noniq - March 27, 2012 0 thanks Makes it possible to use a scope through an association This is a very useful method if you want to to use a scope through an association: class Book < ActiveRecord :: Base scope :available , where ( :available => true ) end class Author < ActiveRecord :: Base has_many :books scope :with_available_books , joins ( :books ). merge ( Book . available ) end # Return all authors with at least one available book: Author . with_available_books See http://asciicasts.com/episodes/215-advanced-queries-in-rails-3 for more info.