localizable_db 1.0.6 → 1.0.7
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/localizable_db/localizable.rb +4 -3
- data/lib/localizable_db/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2417072f63e592da31beda3d43c51ee0892687e285523983a8def07561c7c30c
|
|
4
|
+
data.tar.gz: 7382beda5c96256617bc0f2a756ece69fa24a0d00d7f474b32637d13f8f848f5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: df29f593085bac7f529115270766a118791546ae4af0957241d660a149a77b46caa91cc882aad4972f024f86bf3e7116a18de016e8f8f4561f09b5dac42913c3
|
|
7
|
+
data.tar.gz: 2e83139d802a037df6069c19e87befb3af3829168bd3d38579eb2cfb4ad88999dd27287622201ab38429c55215765248f48a30320dafb6cdea4e549c7d07871e
|
|
@@ -144,7 +144,8 @@ module LocalizableDb
|
|
|
144
144
|
|
|
145
145
|
def with_languages(*with_languages)
|
|
146
146
|
with_languages.flatten!
|
|
147
|
-
with_languages = LocalizableDb::Languages::
|
|
147
|
+
with_languages = with_languages - [LocalizableDb::Languages::DEFAULT] if with_languages.any?
|
|
148
|
+
with_languages = (LocalizableDb::Languages::SUPPORTED - [LocalizableDb::Languages::DEFAULT]) if with_languages.empty?
|
|
148
149
|
attrs_to_select = "#{self.table_name}.*, "
|
|
149
150
|
tables_to_select = "#{self.table_name}, "
|
|
150
151
|
conditions_to_select = ""
|
|
@@ -154,13 +155,13 @@ module LocalizableDb
|
|
|
154
155
|
conditions_to_select += "#{language.to_s}_#{self.localized_table_name}.locale = '#{language.to_s}' AND "
|
|
155
156
|
conditions_to_select += "#{language.to_s}_#{self.localized_table_name}.localizable_object_id = #{self.table_name}.id "
|
|
156
157
|
attrs_to_select += ", " if localized_attribute != self.localized_attributes.last
|
|
157
|
-
conditions_to_select += "AND " if language != with_languages.last
|
|
158
|
+
conditions_to_select += "AND " if language != with_languages.last or localized_attribute != self.localized_attributes.last
|
|
158
159
|
end
|
|
159
160
|
tables_to_select += "#{self.localized_table_name} as #{language.to_s}_#{self.localized_table_name}"
|
|
160
161
|
attrs_to_select += ", " if language != with_languages.last
|
|
161
162
|
tables_to_select += ", " if language != with_languages.last
|
|
162
163
|
end
|
|
163
|
-
result = unscope(:joins)
|
|
164
|
+
result = unscope(:joins).unscope(:select)
|
|
164
165
|
.select(attrs_to_select)
|
|
165
166
|
.from(tables_to_select)
|
|
166
167
|
.where(conditions_to_select)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: localizable_db
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- yonga9121
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2018-02-
|
|
12
|
+
date: 2018-02-12 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: rails
|