Question about Nested Join Tables

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