cancancan_resource_controller 1.0.2 → 1.1.1

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: d65b84894faeb3238628a9b7171979e7b6e472aaac77c0a6012e03393560a38b
4
- data.tar.gz: 610df250cf0731176e364771e64e0fbc5e0c661e143d26060a7b580472811fd8
3
+ metadata.gz: 62a696db74dbddbc518c54bff5cd423e4ae8429d2e3a7b02de751cd6c1a89d9c
4
+ data.tar.gz: 44992376a7f3a3ae5041023048b27a7c8f0bcee4252050fe85de059aa9309e3c
5
5
  SHA512:
6
- metadata.gz: 2be5a3c7cbcdf9589435a6b2b57da0c5fde6454768441528da2a2e1ddaa80526aaf668a68ceee8b3c5f311dec7da16bf6c2445e831bad7fab4165faa2a93a656
7
- data.tar.gz: 80caf64d6786139549aca8617c2fb4e8f194589877b477d5f67ecc947c40e47ff6768afce7cd3722af8b063432cb4e71478502fa32a1c2fb60bfd1df4b5da47a
6
+ metadata.gz: a41161e3b15480fbc5a5a8b21dcb5520dcdb7b16a34e440b1c7fb23661076f867ed4962525e7b39ef5d8ab25fc4977b15ce041d49e617db715bcd6951223c9f5
7
+ data.tar.gz: 7dec4957a61312d6e99d57c59eb91da6acfafe3aa3e7ca08914263b991e33efa8a8faf5ba6e147954f5314abaf514f06dc5a24b003317e0ef10fc45525400dfe
@@ -94,10 +94,27 @@ module CanCanCan
94
94
 
95
95
  def new
96
96
  authorize! :create, @resource_class
97
- @resource ||= @resource_class.new(resource_params)
98
- authorize! :create, @resource
97
+ @resource ||= @resource_class.new
99
98
 
100
- respond_with_resource
99
+ service = CanCanCan::AssignmentAndAuthorization.new(
100
+ current_ability,
101
+ action_name,
102
+ @resource,
103
+ clean_parameter_data(params)
104
+ )
105
+
106
+ if service.call
107
+ respond_with_resource
108
+ else
109
+ begin
110
+ Rails.logger.warn "Failed object validations: could not new #{@resource_class}: #{@resource.errors.full_messages}"
111
+ respond_with_resource_invalid
112
+ rescue Exception => e
113
+ Rails.logger.error "CanCanCanResourceController - Caught Internal Server Error: " + e.class.to_s + ': ' + e.message
114
+ Rails.logger.error Rails.backtrace_cleaner.clean(e.backtrace).join("\n").to_s
115
+ respond_with_resource_error
116
+ end
117
+ end
101
118
  end
102
119
 
103
120
  def edit
@@ -105,13 +122,7 @@ module CanCanCan
105
122
  @resource ||= @resource_class.find(params[:id])
106
123
  authorize! :update, @resource
107
124
 
108
- respond_to do |format|
109
- format.html # Renders the default
110
- format.json { render json: @resources }
111
- format.xml { render xml: @resources }
112
- format.csv # Renders the default
113
- format.xlsx # Renders the default
114
- end
125
+ respond_with_resource
115
126
  end
116
127
 
117
128
  def create
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cancancan_resource_controller
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - benjamin.dana.software.dev@gmail.com