Closed HashNotAdam closed 5 months ago
I was thinking about this PR. And for my use case it doesn't really make sense. A user can have multiple tenants, however when I am allowing the user to switch tenants, there is no current tenant selected. So defining the relationship as a normal has_many
makes more sense to me.
Maybe I am missing something though.
I'm afraid I've dropped Acts As Tenant because I was having too many problems, so I'll just close this
Fixes #283
While previous commits have stated that they support HABTM relationships, acts_as_tenant attempts to set the foreign_key on the record rather than in an association.
This was proven by the new spec in
spec/models/model_extensions_spec.rb
which fails with the error:This PR makes acts_as_tenant aware that these relationships require a new record to be created on the association (unless one already exists).
BREAKING CHANGE
Given an assumption is being made that singular tenant/association names are belongs_to and plural names are has_many, acts_as_tenant will no longer attempt to create a new association if one already exists. This will allow those with non-standard associations to manually define the relationship