multitenant icon indicating copy to clipboard operation
multitenant copied to clipboard

Uniqueness validation

Open mingan opened this issue 9 years ago • 1 comments

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.

mingan avatar Jan 18 '16 14:01 mingan

great idea, and if you have any thoughts on how to organize in the README, I'd gladly accept a pull request.

wireframe avatar Jan 19 '16 17:01 wireframe