wireframe / multitenant

making cross tenant data leaks a thing of the past.
http://blog.codecrate.com/2011/03/multitenant-locking-down-your-app-and.html
MIT License
164 stars 36 forks source link

Uniqueness validation #14

Open mingan opened 8 years ago

mingan commented 8 years ago

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.

wireframe commented 8 years ago

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