standardapi 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/standard_api/views/application/_model.json.jbuilder +14 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dcce074ca51a9c5d78cc73fee9c8849b54216100
|
4
|
+
data.tar.gz: 39e43f30d1541ada3c5d4e9fe8b8955fd2f3c677
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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?(
|
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:
|
20
|
+
json.array! model.send(inc), partial: partial, as: :model, locals: { includes: subinc }
|
11
21
|
else
|
12
|
-
json.partial!
|
22
|
+
json.partial! partial, model: model.send(inc), includes: subinc
|
13
23
|
end
|
14
24
|
end
|
15
25
|
else
|