restful_json 3.3.2 → 3.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OWY3NjI5YzkwZmQ1NGE2OWYwNTkzOGFhYmZlZWM2N2Q2NWYxZmFlZQ==
4
+ YWE3ZThlMmNjMjNkNTgyYjVhMmE0Mjk4NzgyZTljNjI5NWEwYzRmZA==
5
5
  data.tar.gz: !binary |-
6
- MGRhODk2ZjRkNmI2NDU4NjY5OTU4YjQ4MzU4MGI1MTA4NTI3NmJhNQ==
6
+ ZjkzZjY5YThhOGFiYmY1MGE2NWZjYTEwMTQ3NWViMTZlMjVjOWNiMQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NGZiZmM2Yjg2M2VhZTA1MjY3MDIyNTk0ODE1OThmMTlhY2ViZDM4OWZjOWRk
10
- ODFlNWFiODM4YzE4YWRhNDQ3MDYxMDZkMzUxOGZiN2IyYWU3Y2IxM2VkOTg0
11
- MjBlOWM2OTZiNjU4NmE3MTBlNDgyOGUyZGE3NDAwYWFmZTEyNjM=
9
+ NjE5OGM5NWU5ZWFmNGZiZDRjZjUyNDAxOGM5MDRlOWQ2NzVjOWMzNzNiMDMz
10
+ MWUyOGUxMmNkNWM0OTJjZTNmY2RjMGQ2YmJkZGExNDZmMDhiMTRkMmQzMDk1
11
+ NDMxZTM5NzVlZTNkYzI1NWNiYjZkZmVhYzFhNDllMGY2Y2UzZDI=
12
12
  data.tar.gz: !binary |-
13
- YmY5YTNkYmZmZGFmY2U5OGI3ZDk1ZWM1MzliMWZiYzVhYzIwZWE5M2I0M2Rl
14
- NDYwODY4N2MwMjI1YTQ5NDc0MzY1ZWQ0Njc4M2ZhOTBiNWRkMmExYTdmMDMx
15
- NTAyMmNmZmNhMmYxZjJkNzRjOTg5MWZkOTI3YTE2Mzg4MDg3NWY=
13
+ NDgyM2RmNzRhZTdmNjcxZWZkMzg4OWM3MWYxMDVhOTUwYTQ5MjcyZDQ3ZjFi
14
+ YTFhZGY5NjVlMmE5ZWE3MDdlODgyNzdmM2Q1ODkwMjNmYzIzY2JkNWUyNWQ2
15
+ ZWI4NWEyN2ViZmYwMzExMTVhNmRhNjkyMjE2OGQxZGE5MzBjZGM=
@@ -345,21 +345,22 @@ module RestfulJson
345
345
  # The controller's show (get) method to return a resource.
346
346
  def show
347
347
  # to_s as safety measure for vulnerabilities similar to CVE-2013-1854
348
- @value = @model_class.find(params[:id].to_s)
348
+ @value = @model_class.where(id: params[:id].to_s).first # don't raise exception if not found
349
349
  instance_variable_set(@model_at_singular_name_sym, @value)
350
- render_or_respond(true)
350
+ render_or_respond(true, @value.nil? ? :not_found : :ok)
351
351
  end
352
352
 
353
353
  # The controller's new method (e.g. used for new record in html format).
354
354
  def new
355
355
  @value = @model_class.new
356
+ instance_variable_set(@model_at_singular_name_sym, @value)
356
357
  render_or_respond(true)
357
358
  end
358
359
 
359
360
  # The controller's edit method (e.g. used for edit record in html format).
360
361
  def edit
361
362
  # to_s as safety measure for vulnerabilities similar to CVE-2013-1854
362
- @value = @model_class.find(params[:id].to_s)
363
+ @value = @model_class.where(id: params[:id].to_s).first! # raise exception if not found
363
364
  instance_variable_set(@model_at_singular_name_sym, @value)
364
365
  @value
365
366
  end
@@ -395,21 +396,16 @@ module RestfulJson
395
396
  allowed_params = params
396
397
  end
397
398
  # to_s as safety measure for vulnerabilities similar to CVE-2013-1854
398
- @value = @model_class.where(id: params[:id].to_s).to_a[0]
399
- status = :ok
400
- if @value.nil?
401
- status = :not_found
402
- else
403
- @value.update_attributes(allowed_params)
404
- end
399
+ @value = @model_class.where(id: params[:id].to_s).first # don't raise exception
400
+ @value.update_attributes(allowed_params) unless @value.nil?
405
401
  instance_variable_set(@model_at_singular_name_sym, @value)
406
- render_or_respond(false, status)
402
+ render_or_respond(true, @value.nil? ? :not_found : :ok)
407
403
  end
408
404
 
409
405
  # The controller's destroy (delete) method to destroy a resource.
410
406
  def destroy
411
407
  # to_s as safety measure for vulnerabilities similar to CVE-2013-1854
412
- @value = @model_class.where(id: params[:id].to_s).to_a[0]
408
+ @value = @model_class.where(id: params[:id].to_s).first # don't raise exception
413
409
  @value.destroy if @value
414
410
  instance_variable_set(@model_at_singular_name_sym, @value)
415
411
  render_or_respond(false)
@@ -1,3 +1,3 @@
1
1
  module RestfulJson
2
- VERSION = '3.3.2'
2
+ VERSION = '3.3.3'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: restful_json
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.2
4
+ version: 3.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gary S. Weaver
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-10 00:00:00.000000000 Z
12
+ date: 2013-04-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler