class User < ActiveRecord::Base has_many :books has_many :book_users has_many :books, :through => :book_users end class Book < ActiveRecord::Base belongs_to :user has_many :book_users has_many :users, :through => :book_users end An user can write many books An book can belong to only one user An user can be a reader of different books An book can be read by different users
User.books should give me the books the user has written
User.books_read should give me the books, are read by this user
How accomplish this ?
Second question, what is the simplest method to delete book_read from the user ? I mean
User.method_name(book_id) # what's the method name ?