standardapi 1.0.3 → 1.0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 69566409eb2d53c206772fd1bba289eb016269a4
4
- data.tar.gz: bdbbb1c63b34d2eea506cfe63ef1d87a467074cd
3
+ metadata.gz: dcce074ca51a9c5d78cc73fee9c8849b54216100
4
+ data.tar.gz: 39e43f30d1541ada3c5d4e9fe8b8955fd2f3c677
5
5
  SHA512:
6
- metadata.gz: 602ead9fee5724eabfefa6b61510a71f0bf0e0a8b6f2a669561be5d18e44a5ae942bfdca5c1448221336b033dc0f559b687b18ed4449e422726cf9d0bf8852b5
7
- data.tar.gz: 441e7a6b71b9f1bf7aa1d018a3c1c5d3c30753aab585e5fea15afab536b1e82bc26595dbe8e0c3410e356e0015bb7d51d430df549b67d4d158d46ec798ea4471
6
+ metadata.gz: bf58c08c89b8585923f6328de5a1cdd48cf49c8b8edf14dcc72b682ee4275172b7b91e4174302fe29eb6e76c78f9c5c0aa8b93a05f2df14193959f5e41ca9b88
7
+ data.tar.gz: ec704819998b18aa742caa6d30d1a6b4d9403cfba95c46cc64e24ccfec0a8585647db6f821e61c87a96989887e8eed4d73bf356605f31007cb1754e92013d407
@@ -3,13 +3,23 @@ model.attributes.each do |name, value|
3
3
  end
4
4
 
5
5
  includes.each do |inc, subinc|
6
- if model.class.reflect_on_association(inc).klass < ActiveRecord::Base
6
+ association = model.class.reflect_on_association(inc)
7
+ if association.klass < ActiveRecord::Base
7
8
  json.set! inc do
8
- collection = [:has_many, :has_and_belongs_to_many].include?(model.class.reflect_on_association(inc).macro)
9
+ collection = [:has_many, :has_and_belongs_to_many].include?(association.macro)
10
+
11
+ partial = if lookup_context.exists?(association.klass.model_name.element, controller_name)
12
+ # [controller_name, association.klass.model_name.element].join('/')
13
+ association.klass.model_name.element
14
+ else
15
+ # 'application/model'
16
+ 'model'
17
+ end
18
+
9
19
  if collection
10
- json.array! model.send(inc), partial: 'application/model', as: :model, locals: { includes: subinc }
20
+ json.array! model.send(inc), partial: partial, as: :model, locals: { includes: subinc }
11
21
  else
12
- json.partial! 'application/model', model: model.send(inc), includes: subinc
22
+ json.partial! partial, model: model.send(inc), includes: subinc
13
23
  end
14
24
  end
15
25
  else
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: standardapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Bracy