active_record_api-rest 1.0.9 → 1.0.10

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
  SHA256:
3
- metadata.gz: '0284ae32b17d9e2c3f50f363be3bfca4ad200b3dbce2687bc01c8c8a297f95c4'
4
- data.tar.gz: b5d1572d745988e7f5aafcad941e882c552b78ad631a4c633672d1759c119154
3
+ metadata.gz: 5725a7eed108dec0d342fede5c8c2009f4eb34fd00f66ee5bc320ac72d8bd596
4
+ data.tar.gz: 72f6903479ce6fc8b2a7f37d583cdb55f9ac039aea541ff76e312d2a755fd024
5
5
  SHA512:
6
- metadata.gz: b13d5f232ed72e579e7bcfd732f9f5004aa3cfe0569eb7feb49dd04721fcabb96f458b7e86fe3efd83a9585b7539e89dcaff62a0c15b239f612a3d7054ea115d
7
- data.tar.gz: e1b0efb110dbeebb055a59d210f063a19ae78723f23aa8f3d783fcc0fe89095f91dab8bdf9c94bc43bbd462a0151de8ee226e63b7dae1cb5299aa6dda25badf3
6
+ metadata.gz: 80fda6094d96f54182dc0f137296d7f9400b553aca15e7c408267ec85b91acce507b67b062eccc5603159c9628f63b7790c8b54db6a28a933eb0b8a398ba7c7b
7
+ data.tar.gz: 0b41e08348262252dfa058d03aafeed3fb5e83c454e1ea0751058b022599b78b8634cd00ac293b9706332830206f91105bd17cd458f1224ca19ef2bb5429b065
@@ -39,9 +39,12 @@ module ActiveRecordApi
39
39
  protected
40
40
 
41
41
  def redirect_to_model
42
- host = RequestUrlGenerator.new(request: request).micro_service_url
43
- relative_url = url_for(controller: controller_name, action: 'show', id: model.id, only_path: true)
44
- redirect_to "#{host}#{relative_url}", status: :see_other
42
+ redirect_to "#{protocol}://#{request.host_with_port}#{request.path}/#{model.id}", status: :see_other
43
+ end
44
+
45
+ def protocol
46
+ return 'http://' if Rails.env.development?
47
+ 'https://'
45
48
  end
46
49
 
47
50
  def only_valid_params
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ActiveRecordApi
4
4
  module Rest
5
- VERSION = '1.0.9'.freeze
5
+ VERSION = '1.0.10'.freeze
6
6
  end
7
7
  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.9
4
+ version: 1.0.10
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-02 00:00:00.000000000 Z
11
+ date: 2019-04-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -150,7 +150,6 @@ files:
150
150
  - lib/active_record_api/rest/controller.rb
151
151
  - lib/active_record_api/rest/graceful_errors.rb
152
152
  - lib/active_record_api/rest/index_controller.rb
153
- - lib/active_record_api/rest/request_url_generator.rb
154
153
  - lib/active_record_api/rest/spec.rb
155
154
  - lib/active_record_api/rest/spec/rest_controller_shared_example.rb
156
155
  - lib/active_record_api/rest/version.rb
@@ -1,31 +0,0 @@
1
- require 'active_attr'
2
-
3
- module ActiveRecordApi
4
- module Rest
5
- class RequestUrlGenerator
6
- include ActiveAttr::Model
7
-
8
- attribute :request
9
- attribute :new_params, default: {}
10
-
11
- delegate :host, :path, to: :request, prefix: true
12
-
13
- def url
14
- "#{micro_service_url}#{request_path}?#{new_params.to_param}"
15
- end
16
-
17
- def micro_service_url
18
- "#{protocol}#{request_host}/api/#{micro_service_name}"
19
- end
20
-
21
- def micro_service_name
22
- Rails.application.class.parent.to_s.underscore.tr('_', '-')
23
- end
24
-
25
- def protocol
26
- return 'http://' if Rails.env.development?
27
- 'https://'
28
- end
29
- end
30
- end
31
- end