mikeycgto-sinatra-rest 0.4.3 → 0.4.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.
Files changed (2) hide show
  1. data/lib/sinatra/rest/rest.yaml +4 -4
  2. metadata +2 -2
@@ -5,7 +5,7 @@
5
5
  :control: |-
6
6
  @PLURAL = call_model_method(MODEL, :where, mp)
7
7
  :render: |-
8
- if request.xhr?
8
+ if request.xhr? || request.accept.include?('application/json')
9
9
  content_type :json
10
10
  @PLURAL.as_json.to_json
11
11
  else
@@ -30,7 +30,7 @@
30
30
  if @SINGULAR.errors.empty?
31
31
  redirect url_for_PLURAL_show(@SINGULAR), 'SINGULAR created'
32
32
  else
33
- if request.xhr?
33
+ if request.xhr? || request.accept.include?('application/json')
34
34
  throw :halt, [500, @SINGULAR.errors.full_messages.join("\n")]
35
35
  else
36
36
  RENDERER :'PLURAL/new', options
@@ -46,7 +46,7 @@
46
46
  if @SINGULAR.nil?
47
47
  throw :halt, [404, 'SINGULAR not found']
48
48
  else
49
- if request.xhr?
49
+ if request.xhr? || request.accept.include?('application/json')
50
50
  content_type :json
51
51
  @SINGULAR.as_json.to_json
52
52
  else
@@ -75,7 +75,7 @@
75
75
  if @SINGULAR.errors.empty?
76
76
  redirect url_for_PLURAL_show(@SINGULAR), 'SINGULAR updated'
77
77
  else
78
- if request.xhr?
78
+ if request.xhr? || request.accept.include?('application/json')
79
79
  throw :halt, [500, @SINGULAR.errors.full_messages.join("\n")]
80
80
  else
81
81
  RENDERER :'PLURAL/edit', options
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 4
8
- - 3
9
- version: 0.4.3
8
+ - 4
9
+ version: 0.4.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - blindgaenger