A classic HABTM!
Class User < ActiveRecord::Base
has_many :books, :through => :book_shelves
end
Class BookShelve < ActiveRecord::Base
belongs_to :user
has_many :books
end
Class Book < ActiveRecord::Base
belongs_to :user, :through => :book_shelves
end
You can get the list of books like so:
Hi,
I've been trying to read ActiveRecord tutorials etc. but haven't
figured out how to get the information I want. Let's say I have a
users who own one to many bookshelves and some of these bookshelves
contain books. Now I would like to get a list of books that belong to
user named Timeon:
SELEC
2 matches
Mail list logo