[Rails] Re: Re: Modelling Question

2010-03-07 Thread Max Williams
I don't think you could do all of this with the standard nested_attributes on the book model, you'd need to write your own setter method. Ultimately you're going to be creating an authoring_role object, and either finding an existing author or creating a new author, and the same for the role.

Re: [Rails] Re: Re: Modelling Question

2010-03-05 Thread Andy Jeffries
> > Rails finds it easier to use foreign keys based on id. Are we talking > about rails or about a person manually searching the database using > their hands and eyes? > A person manually scanning the database (in a MySQL command prompt). If this was actually a useful table (as opposed to just i

[Rails] Re: Re: Modelling Question

2010-03-05 Thread Max Williams
Andy Jeffries wrote: >> >> Also by using a string for the role_type you will have many Role >> records with "MAIN_AUTHOR" for example. If you later decided that >> "Primary Author" would be better you would have to change the string >> in many records. > > > I'm not saying MAIN_AUTHOR has to be

[Rails] Re: Re: Modelling Question

2010-03-05 Thread Max Williams
Also, your system doesn't easily let you attach properties or behaviour to a given role. Presumably you would have a field 'name', or something similar, in the roles table, and you could hang behaviour on the value of the name but again it's clumsy and messy and fragile, and creates a lot of r

[Rails] Re: Re: Modelling Question

2010-03-05 Thread Max Williams
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 cl