Sorry for the delay in getting back on this but I’ve just got back from a weekend away.
Okay, so Max, you and I agree on the modelling for this concept so that starts to narrow down where my problem is.
To begin with, I thought my problem was because I had a join model acting as the parent to another join model and maybe the primary key of Authorings wasn’t being created before the join to AuthoringRole was being made.
Where we disagree is in the relationships and so this is obviously where my problem lies.
I agree with all your relationships but I’ve added a bit extra … In my book.rb, I have included accepts_nested_attributes_for :authors, :authoring_roles
and also have a has_many :authoring_roles, :through => :authorings
I’ve done this because I want to accept all that information when creating a book. when I say @book.save, I want it to include the roles as well as the authors.
So how should I set that up? In my real world example Book == Account, Author == Member and Role is one or many of Account Contact/Swimmer/etc.
When creating a new Book (Account), I am creating a new Author (Member) and so the form accepts_nested_attributes_for :authors, :authoring_roles (in my obviously mixed up logic)
If I have a form where I accept Book, Author and Role information and then want to create/update the Book, Author, Authorings and AuthoringRoles through @book,save, how to go about it?
I’ll have a play with this now and if I can break myself out of my cycle and crack it, I’ll get in touch. If you/someone provides me the solution before that, I’d be grateful as this has been sending me mad.
Merci
-Ants