Question about Nested Join Tables

Anthony Gardner
Wed, 03 Mar 2010 23:49:01 -0000

I have five tables that I am trying to get to work nicely together but may
need some help.

I have three main tables: accounts, members and roles. With two join tables
account_members and account_member_roles.

The accounts and members table are joined by account_members (fk account_id
and member_id) table (many-to-many). No problem.

The other 2 tables are the problem (roles and account_member_roles).

A member of an account can have more than one role and I have the
account_member_roles (fk account_member_id and role_id)
 table joining the account_members join table and the roles table.

That seems logical (an account_member can have many roles
(account_member_roles), unless anyone thinks differently. What I''d like
to
be able to do is when creaeting an account, for instance, I would like
@account.save to include the roles and update the account_member_roles table
neatly ..... but through the account_members join table.

accept_nested_attributes_for :members exist in the account.rb so that''s
no
problem but I''d like a nested/nested accept_nested_attributes_for
:account_member_roles in account.rb

I''ve tried an accept_nested_attributes_for in the join model
account_member.rb but it doesn''t work (even though logically
that''s how it
is)

It''s late so maybe I''m overlooking something simple here or
maybe there''s a
better approach.

CIA

-ants

--
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at