ash_phoenix icon indicating copy to clipboard operation
ash_phoenix copied to clipboard

Add Multitenancy Support to ash_phoenix.gen.live & ash_phoenix.gen.html

Open jeffhuen opened this issue 11 months ago • 3 comments

Currently, mix ash_phoenix.gen.live does not natively support multitenancy. For users building SaaS applications with Ash and AshPostgres, handling multitenancy requires manual intervention.

Generated LiveView pages do not automatically respect tenant context, requiring additional modifications to: • Ensure LiveView sessions and queries include tenant information. • Modify mount/3 in generated LiveViews to retrieve and apply the correct tenant. • Adjust the router to properly assign tenants for multitenant-aware resources.

Without first-class support for multitenancy in ash_phoenix.gen.live, developers need to manually patch these issues every time they generate a new resource.

jeffhuen avatar Feb 12 '25 20:02 jeffhuen

hey @zachdaniel and ash team, just wondering here, ash.gen.live template can be overwritten like the phoenix ones? I'm asking because this kind of issue could be also fixed that way.

jfriboldi avatar May 26 '25 15:05 jfriboldi

Not currently no :) But PRs to make that possible are welcome. With that said, it's probably not much harder to write your own, because our generators only generate the live views. We don't generate other stuff like schemas/contexts etc.

zachdaniel avatar May 26 '25 17:05 zachdaniel

Thanks for the fast reply, maybe I can give a try.

jfriboldi avatar May 26 '25 17:05 jfriboldi