effective_resources 0.7.7 → 0.7.8
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3deaacf629c453d765b048261350ddc03cc9f45e
|
4
|
+
data.tar.gz: 25fc0245a9598ad7c007de51b19e7fa1ca3e3df5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f928dcba37bb38344262d307c254476456af1055df9e4a0f83f47c33da92bc153735b1c220f7b3719e323ae9dac6832460a6d3ab4b8279f2c64b2575f822177
|
7
|
+
data.tar.gz: 75fa4e057ce348f2090a5afdf7d805493b026b8fe9a8dfe8164d7c9f6f3b274c70433f98d96cedcce203639b90b963c80eeed90997474d47e69e7a5106497daf
|
@@ -39,9 +39,9 @@ module Effective
|
|
39
39
|
def belongs_to(name)
|
40
40
|
if name.kind_of?(String) || name.kind_of?(Symbol)
|
41
41
|
name = (name.to_s.end_with?('_id') ? name.to_s[0...-3] : name).to_sym
|
42
|
-
belong_tos.find { |ass| ass.name == name }
|
42
|
+
belong_tos.find { |ass| ass.name == name && !ass.options[:polymorphic] }
|
43
43
|
else
|
44
|
-
belong_tos.find { |ass| ass.klass == name.class }
|
44
|
+
belong_tos.find { |ass| ass.klass == name.class && !ass.options[:polymorphic] }
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
@@ -26,8 +26,8 @@ module Effective
|
|
26
26
|
.order(order_by_associated_conditions(association, sort: sort, direction: direction, limit: limit))
|
27
27
|
when :belongs_to_polymorphic
|
28
28
|
relation
|
29
|
-
.order("#{sql_column
|
30
|
-
.order("#{sql_column} #{sql_direction}")
|
29
|
+
.order("#{sql_column}_type #{sql_direction}")
|
30
|
+
.order("#{sql_column}_id #{sql_direction}")
|
31
31
|
when :has_and_belongs_to_many, :has_many, :has_one
|
32
32
|
relation
|
33
33
|
.order(order_by_associated_conditions(association, sort: sort, direction: direction, limit: limit))
|
@@ -77,10 +77,10 @@ module Effective
|
|
77
77
|
(type, id) = term.split('_')
|
78
78
|
|
79
79
|
if type.present? && id.present?
|
80
|
-
relation.where("#{sql_column} = ?", id).where("#{sql_column
|
80
|
+
relation.where("#{sql_column}_id = ?", id).where("#{sql_column}_type = ?", type)
|
81
81
|
else
|
82
82
|
id ||= Effective::Attribute.new(:integer).parse(term)
|
83
|
-
relation.where("#{sql_column} = ? OR #{sql_column
|
83
|
+
relation.where("#{sql_column}_id = ? OR #{sql_column}_type = ?", id, (type || term))
|
84
84
|
end
|
85
85
|
when :effective_addresses
|
86
86
|
relation.where(id: Effective::Resource.new(association).search_any(value, fuzzy: fuzzy).pluck(:addressable_id))
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_resources
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-01-
|
11
|
+
date: 2018-01-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|