rails_db_localize 0.0.5 → 0.0.6
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/lib/ext/active_record_ext.rb +13 -2
- data/lib/rails_db_localize/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8600b561b5975cc6b3f30e874b2a4e8a07f1da20
|
4
|
+
data.tar.gz: 633843082b8111ac51b6ab1b2a3aa68ca6ef2daa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 131df9c32f5c90bd90844dcddef5666e7d722628712bb5a3d64fab7abb135a4e149adf3ec1c9dafbc5af6f2b3fae18f6c23110bd4e446e9b6608d21cd137d34f
|
7
|
+
data.tar.gz: c271edfd2a41a9e6ddd6c1a421cf9bd645816eae4bd0f7b74aaa666421f90be30e7fbb36068ec5044e32ea25670aee219f1e807cc3ed9efa7b197902126cc662
|
@@ -8,10 +8,21 @@ class ActiveRecord::Base
|
|
8
8
|
# Register it mostly to remove the translations once you delete an object
|
9
9
|
has_many :translations, class_name: "RailsDbLocalize::Translation", as: :resource, dependent: :destroy
|
10
10
|
|
11
|
+
|
11
12
|
scope :__rails_db_translations_sub_query, lambda{ |lang|
|
12
|
-
|
13
|
+
adapter = Rails.configuration.database_configuration[Rails.env]["adapter"]
|
14
|
+
|
13
15
|
number_of_fields_to_translates = RailsDbLocalize.schema[self.to_s].count
|
14
16
|
|
17
|
+
having_clause = case adapter
|
18
|
+
when 'postgresql'
|
19
|
+
lambda{ "COUNT(*) == #{number_of_fields_to_translates}::bigint" }
|
20
|
+
else
|
21
|
+
lambda{ "COUNT(*) == #{number_of_fields_to_translates}" }
|
22
|
+
end
|
23
|
+
|
24
|
+
ttable = RailsDbLocalize::Translation.arel_table.name
|
25
|
+
|
15
26
|
# We can unscope, but problems tend to appears
|
16
27
|
# with some gems like paranoid.
|
17
28
|
table = respond_to?(:klass) ? table.klass : self
|
@@ -20,7 +31,7 @@ class ActiveRecord::Base
|
|
20
31
|
ON (\"#{ttable}\".resource_id = \"#{arel_table.name}\".id
|
21
32
|
AND \"#{ttable}\".resource_type = '#{to_s}')")
|
22
33
|
.group(:resource_type, :resource_id)
|
23
|
-
.having(
|
34
|
+
.having(having_clause.call)
|
24
35
|
.where(:"rails_db_localize_translations.lang" => lang)
|
25
36
|
}
|
26
37
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_db_localize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yacine PETITPREZ
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|