Given the Book collection, what's the best way to find all the "authors" (no duplicates)?
So, let's say we have a classic association:
class Author < ActiveRecord::Base has_many :books end class Book < ActiveRecord::Base belongs_to :author end
The way I'm doing it right now is:
@books = Book.where("some condition") @authors = Author.where(:id => @books.map(&:author_id))
Is there a better way to do this?
source share