Why primary key does not autogenerate when doing many to many assoc?

Ignore - I just read this:

given :through associations are read-only


After this remark I have to wonder whether many_to_many may be better represented as:

# User.ex

has_many :user_permissions, Accounts.UserPermission
has_many :user_actions, through: [:user_permissions, :permission]

# :user_permissions - has_many association in this schema, the User
# :permission       - belongs_to association in UserPermission schema

See Ecto.Schema: has_many/has_one :through

Another has_many :through example.

1 Like