I have a two tables joined with a join table - this is just pseudo code:
Library Book LibraryBooks
What I need to do is if i have the id of a l
One problem with
l.books.map{|b| b.libraries}.flatten.uniq
is that it will generate one SQL call for each book in l. A better approach (assuming I understand your schema) might be:
LibraryBook.find(:all, :conditions => ['book_id IN (?)', l.book_ids]).map(&:library_id).uniq