acts_as_tenant 2.0.2 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +14 -0
- data/lib/acts_as_tenant/locale/en.yml +7 -0
- data/lib/acts_as_tenant/model_extensions.rb +2 -2
- data/lib/acts_as_tenant/version.rb +1 -1
- data/lib/acts_as_tenant.rb +4 -0
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 83cdd10871addd92f256ed17b6e49a841de127487d7e165011348a40a0185f01
|
|
4
|
+
data.tar.gz: b45e0af7799acd0fc982c1af602e3384dd2637b930901cfd4f731263a7cf5c7f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5a3373802ec3b706290d9277c7a3704055f15ebd4028d29d3b797b1f228a62f2d8168a0ce357a5ae8a25f8748c63eab735545ba007807fe5c2f96a1dc76ab4a7
|
|
7
|
+
data.tar.gz: aa31a475db70064a9a8edeae329456b82e7225a000008d5fa93ef2c9c265b7c8ae1e59c0111172d26232e037d19a7e1324f2e176c981fbc070144f0b3c906424
|
data/README.md
CHANGED
|
@@ -210,6 +210,20 @@ New records are assigned the current tenant unless they already have one. A reco
|
|
|
210
210
|
|
|
211
211
|
When no tenant is set (for example in an admin panel or inside `without_tenant`), `belongs_to` associations to tenanted models are validated to belong to the same tenant as the record. Associated records without a tenant, such as global records, are allowed.
|
|
212
212
|
|
|
213
|
+
The validation error messages can be overridden in your locale files, using the same lookup as other Active Record errors:
|
|
214
|
+
|
|
215
|
+
```yaml
|
|
216
|
+
en:
|
|
217
|
+
activerecord:
|
|
218
|
+
errors:
|
|
219
|
+
messages:
|
|
220
|
+
acts_as_tenant:
|
|
221
|
+
tenant_mismatch: "must be the current tenant"
|
|
222
|
+
association_invalid: "is invalid"
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
Messages can also be overridden for one model or one attribute, such as `activerecord.errors.models.task.acts_as_tenant.association_invalid` or `activerecord.errors.models.task.attributes.project_id.acts_as_tenant.association_invalid`.
|
|
226
|
+
|
|
213
227
|
### Validating attribute uniqueness
|
|
214
228
|
|
|
215
229
|
If you need to validate for uniqueness, chances are that you want to scope this validation to a tenant. You can do so by using:
|
|
@@ -107,7 +107,7 @@ module ActsAsTenant
|
|
|
107
107
|
matches = record_id.to_s == current_tenant.public_send(pkey).to_s
|
|
108
108
|
matches &&= record_type == current_tenant.class.polymorphic_name if options[:polymorphic]
|
|
109
109
|
|
|
110
|
-
record.errors.add(fkey, "
|
|
110
|
+
record.errors.add(fkey, :"acts_as_tenant.tenant_mismatch") unless matches
|
|
111
111
|
end
|
|
112
112
|
|
|
113
113
|
# Associations are looked up at validation time so belongs_to associations
|
|
@@ -144,7 +144,7 @@ module ActsAsTenant
|
|
|
144
144
|
end
|
|
145
145
|
|
|
146
146
|
if associated.nil? || tenant_mismatch.call(record, associated)
|
|
147
|
-
record.errors.add
|
|
147
|
+
record.errors.add(attr, :"acts_as_tenant.association_invalid")
|
|
148
148
|
end
|
|
149
149
|
end
|
|
150
150
|
end
|
data/lib/acts_as_tenant.rb
CHANGED
|
@@ -137,6 +137,10 @@ module ActsAsTenant
|
|
|
137
137
|
end
|
|
138
138
|
end
|
|
139
139
|
|
|
140
|
+
ActiveSupport.on_load(:i18n) do
|
|
141
|
+
I18n.load_path << File.expand_path("acts_as_tenant/locale/en.yml", __dir__)
|
|
142
|
+
end
|
|
143
|
+
|
|
140
144
|
ActiveSupport.on_load(:active_record) do |base|
|
|
141
145
|
base.include ActsAsTenant::ModelExtensions
|
|
142
146
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: acts_as_tenant
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.0
|
|
4
|
+
version: 2.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Erwin Matthijssen
|
|
@@ -44,6 +44,7 @@ files:
|
|
|
44
44
|
- lib/acts_as_tenant/controller_extensions/subdomain.rb
|
|
45
45
|
- lib/acts_as_tenant/controller_extensions/subdomain_or_domain.rb
|
|
46
46
|
- lib/acts_as_tenant/errors.rb
|
|
47
|
+
- lib/acts_as_tenant/locale/en.yml
|
|
47
48
|
- lib/acts_as_tenant/model_extensions.rb
|
|
48
49
|
- lib/acts_as_tenant/sidekiq.rb
|
|
49
50
|
- lib/acts_as_tenant/tenant_helper.rb
|
|
@@ -68,7 +69,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
68
69
|
- !ruby/object:Gem::Version
|
|
69
70
|
version: '0'
|
|
70
71
|
requirements: []
|
|
71
|
-
rubygems_version: 4.0.
|
|
72
|
+
rubygems_version: 4.0.20
|
|
72
73
|
specification_version: 4
|
|
73
74
|
summary: Add multi-tenancy to Rails applications using a shared db strategy
|
|
74
75
|
test_files: []
|