erwinm/acts_as_tenant ? reverse-engineered prompt
Reverse engineered prompt
Build me a Ruby gem for Rails that makes multi tenant apps easy to use with one shared database.
I want models to automatically stay scoped to the current tenant, so when someone looks up, creates, or updates records, they only see data for their own account. It should work with a tenant model like Account, and it should let me set the current tenant from a subdomain, from my controller, or for a block of code in background jobs.
Please also add a way to require a tenant, temporarily turn tenant checks off for admin style pages, and temporarily allow changing a record’s tenant when needed. It would be great if it includes a uniqueness helper for validations within one tenant, plus a helper for accessing the current tenant in views.
Make sure it feels safe by default, thread safe, and easy to drop into a normal Rails app without a lot of setup. If you need to, look up current Rails docs online for the cleanest approach.
Are you gonna build this?
make sure you review the code using coderabbit