multitenant
multitenant copied to clipboard
Uniqueness validation
Today, I noticed that when using validates :field, uniqueness: true
on a model with belongs_to_multitenant
doesn't cause the validation query to be restricted to the tenant.
My goal was a tenant-scoped uniqueness, but one could argue that application wide uniqueness can be meaningful in multitenant applications as well. In that spirit, I don't think it is a bug, but a sentence like "Multitenant doesn't affect Rails built-in uniqueness validation; for tenant-scoped validation use validates :field, uniqueness: { scope: :tenant_id }
" in the readme would be helpful.
great idea, and if you have any thoughts on how to organize in the README, I'd gladly accept a pull request.