active_record_api-rest 1.0.10 → 1.0.11
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/active_record_api/rest/controller.rb +9 -11
- data/lib/active_record_api/rest/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: 4ab132ecc0b2f3ccd7c4c151674e9c2623450c674fb88aee69e4277f9510a7ba
|
4
|
+
data.tar.gz: d2e16fa7cb20a80c1104f2f71f576a0791e585d52e8f227d54eb3d79472d0417
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6bbd71ac2d4987ac9c54a3eb840d71b536959c1f47aa1116124a4f805477e1c4f0300548ab28714ba1f14338156dcaf202662d18bf4cf62aa046b66f66db5798
|
7
|
+
data.tar.gz: c22e0faaae9fea5191fdf34449368fe8533ca85de1fe7111bb6aa6b8c419ae5bb6782cfaa357bfd186fbf6bc163134154524249886b8bd0e65e192e03ab4dac0
|
@@ -24,7 +24,7 @@ module ActiveRecordApi
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def update
|
27
|
-
if model.update(
|
27
|
+
if model.update(filtered_params)
|
28
28
|
redirect_to_model
|
29
29
|
else
|
30
30
|
render json: model.errors, status: :unprocessable_entity
|
@@ -39,7 +39,11 @@ module ActiveRecordApi
|
|
39
39
|
protected
|
40
40
|
|
41
41
|
def redirect_to_model
|
42
|
-
|
42
|
+
if request.path.include?(model.id)
|
43
|
+
redirect_to "#{protocol}#{request.host_with_port}#{request.path}", status: :see_other
|
44
|
+
else
|
45
|
+
redirect_to "#{protocol}#{request.host_with_port}#{request.path}/#{model.id}", status: :see_other
|
46
|
+
end
|
43
47
|
end
|
44
48
|
|
45
49
|
def protocol
|
@@ -52,14 +56,8 @@ module ActiveRecordApi
|
|
52
56
|
render json: { base: "Extra parameters are not allow: #{not_allowed_params.join(', ')}" }, status: :unprocessable_entity
|
53
57
|
end
|
54
58
|
|
55
|
-
def resource_params
|
56
|
-
@resource_params ||= filtered_params.reject do |column_name|
|
57
|
-
column_name.to_s == 'id'
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
59
|
def not_allowed_params
|
62
|
-
@not_allowed_params ||= ((params.keys.map(&:to_sym) - [:controller, :action, :id, controller_name.singularize.to_sym]) -
|
60
|
+
@not_allowed_params ||= ((params.keys.map(&:to_sym) - [:controller, :action, :id, :created_at, :updated_at, controller_name.singularize.to_sym]) - filtered_params.keys.map(&:to_sym))
|
63
61
|
end
|
64
62
|
|
65
63
|
def load_model
|
@@ -80,7 +78,7 @@ module ActiveRecordApi
|
|
80
78
|
end
|
81
79
|
|
82
80
|
def filtered_params
|
83
|
-
@
|
81
|
+
@simple_params = params.permit!.to_h.select! { |key, _value| allowed_params.include?(key.to_sym) }
|
84
82
|
end
|
85
83
|
|
86
84
|
def allowed_params
|
@@ -92,7 +90,7 @@ module ActiveRecordApi
|
|
92
90
|
else
|
93
91
|
col
|
94
92
|
end
|
95
|
-
end
|
93
|
+
end - %i[created_at updated_at id]
|
96
94
|
end
|
97
95
|
|
98
96
|
def column_definition(column_name)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_record_api-rest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Full Measure Education
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-04-
|
11
|
+
date: 2019-04-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|