Ash FrameworkAF
Ash Framework3y ago
10 replies
harry

`many_to_many` error

    ** (RuntimeError) Resource `SwiftEco.Resources.Accounts.UsersCompanies` is not in registry `SwiftEco.Resources.Companies` for autogenerated join relationship: `:users_join_assoc`

Relationship was generated by the `many_to_many` relationship `:users`

If the `through` resource `SwiftEco.Resources.Accounts.UsersCompanies` is not accepted by the same
api as the destination resource `SwiftEco.Resources.Accounts.User`,
then you must define that relationship manually. To define it manually, add the following to your
relationships:

    has_many :users_join_assoc, SwiftEco.Resources.Accounts.UsersCompanies do
      # configure the relationship attributes
      ...
    end

You can use a name other than `:users_join_assoc`, but if you do, make sure to
add that to `:users`, i.e

    many_to_many :users_join_assoc, SwiftEco.Resources.Accounts.UsersCompanies do
      ...
      join_relationship_name :your_new_name
    end

Happy to share any code needed just not sure what the actual error means! It was working before and I have just started work on tidying up the codebase and this is now an error that has appeared
Was this page helpful?