In the following hypothetical scenario, I'd like to associate Books
Class Club < ActiveRecord::Base
has_many :readers, :through => :memberships
#DOES NOT WORK
#has_many :books, :through => :readers
#DOES NOT ADD find_in_collection METHODS
#has_many :books, :finder_sql =>
# select distinct books.*
# from books
# join memberships on books.reader_id
# and memberships.club_id =
# order by books.read_at desc
Class Memberships < ActiveRecord::Base
Class Reader < ActiveRecord::Base
Class Book < ActiveRecord::Base
If Memberships were simply a mapping table (clubs_readers) and class
Club has_and_belongs_to_many :readers, I still couldn't specify that
class Club has_many :books, :through => :readers because you can't
associate through habtm.
Unfortunately, associating books through readers in class Club does
not work because readers is associated through memberships.
Apparently, multiple levels of indirection is not supported.
If you use finder_sql, all the find_in_collection methods are not
added to the association proxy. Without which I won't be able to call
my_club.books.find(:all, :conditions => 'is_read = true') or to do
pagination for example.
Does anyone have any idea how I can create this association without
finder_sql and perhaps extending the association proxy?