Question about Nested Join Tables

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

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

The accounts and members table are joined by account_members (fk
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
be able to do is when creaeting an account, for instance, I would like to include the roles and update the account_member_roles
neatly … but through the account_members join table.

accept_nested_attributes_for :members exist in the account.rb so that’s
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’s late so maybe I’m overlooking something simple here or maybe
there’s a
better approach.