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: 1aa7e76fe50300298a588eba9b2e78cebb8fc8fa
4
- data.tar.gz: c2f1e411a4bee8da004429832034947e215a6e5a
3
+ metadata.gz: 3deaacf629c453d765b048261350ddc03cc9f45e
4
+ data.tar.gz: 25fc0245a9598ad7c007de51b19e7fa1ca3e3df5
5
5
  SHA512:
6
- metadata.gz: 7e9698bc84efc80a4c45b9ed43edc576375167139c729469f8e07bb6aef69b8f344d65d802d8fd72f4e07ff9a8b2377cd7a327cfd51a30d4d0a272f9e085bb7a
7
- data.tar.gz: b620b567f3eb8c6312ad1b0ae324af77816b56e22bfaaaad0ce3c51ae6c2268e8d830f70c397ababb46d3e070ff22a92fb71210ca9862b3a04a9a3a15bc8bff0
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.sub('_id', '_type')} #{sql_direction}")
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.sub('_id', '_type')} = ?", type)
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.sub('_id', '_type')} = ?", id, (type || term))
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))
@@ -1,3 +1,3 @@
1
1
  module EffectiveResources
2
- VERSION = '0.7.7'.freeze
2
+ VERSION = '0.7.8'.freeze
3
3
  end
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.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 00:00:00.000000000 Z
11
+ date: 2018-01-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails