Multiple Tenant Resources
In my app, I have two tenant resources:
Organization
and Establishment
. I'm using the new scope
feature and the value for current_tenant
is a map containing both tenants. I need to provide an Ash.ToTenant
implementation that extracts the correct tenant depending on the resource being queried.
I've tried this:
But I'm getting the following error:
And when I provide implementations for the Map
type:
It works but, I get the following warning:
Should I just ignore it, or is there a better approach to this?4 Replies
Are you potentially passing a map around as the tenant instead of the struct? You shouldn't need to do that.
To define the protocol for map I mean
Yeah, so, given that I have two tenant resources, my
current_tenant
value in my Ash.Scope
is a map containing both tenants. So my goal is to define an implementation that allows Ash to extract the corresponding tenant depending on the resource.
I'm trying this, what do you think?
Ah, interesting. Yeah that makes sense.
I think 🙂
I hadn't considered the use case TBH so you'll want to play around with it
Yeah, I'll leave this open until I'm sure this approach works for child resources in both tenants. So far so good, the implementation error is gone. I'll share any updates 🙂