active_record_api-rest 1.0.22 → 1.0.23
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
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 731b4376a9b6a9554968df8bc13f8489153c5f526790a494627ff0abebfcc2e8
|
|
4
|
+
data.tar.gz: cc7cec74d8fbbf6dd9e29df2b95c1091b2f85640123aff159327b9f6361997c5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7f17acf6b275fdd0427cd9af56cc08c8b8b8e221f7a07155dce0578ce0a4b5e77faad8052b43048f5b9133d3ad590a19c1b2c3766a506b3b0995147e2539aa33
|
|
7
|
+
data.tar.gz: c7695d96bac9774c3ed7649fee44696ec388ce089fe3386fa4fdff6e693d0deb7bec2a3c5d9dbdc926d1d0b81f4018cd87845316ef3ea8f1485f7465d4abf8bd
|
|
@@ -3,7 +3,7 @@ module ActiveRecordApi
|
|
|
3
3
|
class Controller < ApplicationController
|
|
4
4
|
include GracefulErrors
|
|
5
5
|
delegate :previous_id, :limit, :queryable_params, :modifiable_params, :not_allowed_params, to: :parameters
|
|
6
|
-
delegate :next_url, to: :request_url_generator
|
|
6
|
+
delegate :next_url, :redirect_url, to: :request_url_generator
|
|
7
7
|
before_action :initialize_model, only: :create
|
|
8
8
|
before_action :validate_params
|
|
9
9
|
|
|
@@ -19,7 +19,7 @@ module ActiveRecordApi
|
|
|
19
19
|
|
|
20
20
|
def create
|
|
21
21
|
if model.save
|
|
22
|
-
|
|
22
|
+
redirect_to redirect_url(model), status: :see_other
|
|
23
23
|
else
|
|
24
24
|
render json: model.errors, status: :unprocessable_entity
|
|
25
25
|
end
|
|
@@ -27,7 +27,7 @@ module ActiveRecordApi
|
|
|
27
27
|
|
|
28
28
|
def update
|
|
29
29
|
if model.update(modifiable_params)
|
|
30
|
-
|
|
30
|
+
redirect_to redirect_url(model), status: :see_other
|
|
31
31
|
else
|
|
32
32
|
render json: model.errors, status: :unprocessable_entity
|
|
33
33
|
end
|
|
@@ -17,6 +17,14 @@ module ActiveRecordApi
|
|
|
17
17
|
"#{current_url}?#{new_params.to_param}"
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
+
def redirect_url(model)
|
|
21
|
+
if action_name == 'update'
|
|
22
|
+
current_url
|
|
23
|
+
else
|
|
24
|
+
"#{current_url}/#{model.id}"
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
20
28
|
def new_params
|
|
21
29
|
query_parameters.dup.merge(pagination_param_name.to_s => models_remaining.limit(limit).last.send(pagination_param_name))
|
|
22
30
|
end
|
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.23
|
|
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-23 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|