Hi Andy - why not just post your code here?  Saves clicking away, and 
it's easier to discuss the code.  Anyway, you posted

class Role < ActiveRecord::Base
  belongs_to :author
  belongs_to :book
end

class Book < ActiveRecord::Base
  has_many :authors, :through => :roles
  has_many :roles
end

class Author < ActiveRecord::Base
  has_many :books, :through => :roles
  has_many :roles
end

The problem with this is this part of the description: "An Author can 
also have one or many roles associated with a book " - with "or many" 
being the key part.

In your system, let's say that David Smith is the editor of and a 
contributor to a book called "Advances in web design".  Then you have 
two roles objects linking david to the book.  That makes it look like 
two people worked on the book, who happen to be the same person, and it 
makes it look like david wrote two books that happen to be the same 
book.  This is confusing.  If i want to know, for example, how many 
books David has worked on, i'd expect the answer to be 1, not 2.  You 
could get around this by calling 'uniq' on the results of .books or 
.authors, but it's unintuitive and fragile.
-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to