Re: [Rails] Trivial SQL query - how to do it with ActiveRecord?

2011-08-18 Thread Dheeraj Kumar
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:

[Rails] Trivial SQL query - how to do it with ActiveRecord?

2011-08-18 Thread timeon
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