abstracted 0.4.9 → 0.4.10
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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 829e21cb1af7f63f290d7e843cfdb842177f982d
|
4
|
+
data.tar.gz: caf2682e6db0978d768bbef23fbb9650ff3a8bf6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 908fd779e22d8df77a269cab628612692737adc18f20f1ba0195e40cf4ff2f6aa2c26624c2f6c5a7c83f069ef21092a32424335961c68b71d2e3c83826e1ff5a
|
7
|
+
data.tar.gz: 5b3b91a3ce24e678104c553197d40cc0573d7ff9f42ae8596e8246e54825272a5cbf2c2888bfff720f6963b103b3a983afac9e2d2cf292d2535e5735ac51590e
|
@@ -8,7 +8,6 @@ class AbstractResourcesController < ApplicationController
|
|
8
8
|
respond_to :html, :xml, :js, :json #, :xlsx
|
9
9
|
|
10
10
|
before_action :authenticate_user!
|
11
|
-
before_action :set_paper_trail_whodunnit
|
12
11
|
|
13
12
|
include PrintControl
|
14
13
|
include ResourceControl
|
@@ -170,7 +169,7 @@ class AbstractResourcesController < ApplicationController
|
|
170
169
|
|
171
170
|
def destroy
|
172
171
|
authorize resource
|
173
|
-
result = true if
|
172
|
+
result = true if delete_resource && update_parenthood
|
174
173
|
result ? (flash.now[:notice] = t('.success', resource: resource_class.to_s)) : (flash.now[:error] = t('.deleted.error',resource: resource_class.to_s))
|
175
174
|
if result==true
|
176
175
|
render layout:false, status: 200, locals: { result: true }
|
@@ -183,6 +182,14 @@ class AbstractResourcesController < ApplicationController
|
|
183
182
|
|
184
183
|
private
|
185
184
|
|
185
|
+
def delete_resource
|
186
|
+
if resource.respond_to? :deleted_at
|
187
|
+
resource.update_attributes deleted_at: Time.now
|
188
|
+
else
|
189
|
+
resource.destroy
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
186
193
|
# you can override this on your controller
|
187
194
|
def redirect_after_create
|
188
195
|
resources_url {}
|
@@ -107,7 +107,7 @@ module ResourceControl
|
|
107
107
|
def resources_url options={}
|
108
108
|
r=request.path
|
109
109
|
options = case params[:action]
|
110
|
-
when 'create','update','delete','destroy';
|
110
|
+
when 'create','update','delete','destroy'; {}
|
111
111
|
else resource_options(options)
|
112
112
|
end
|
113
113
|
return "%s%s" % [r,options] if r.match "#{resource.class.to_s.tableize}$"
|
@@ -116,9 +116,9 @@ module ResourceControl
|
|
116
116
|
scoop_from_error e
|
117
117
|
end
|
118
118
|
|
119
|
-
def resource_options options
|
119
|
+
def resource_options options
|
120
120
|
options.merge! params.except( "id", "controller", "action", "utf8", "_method", "authenticity_token" )
|
121
|
-
options.empty? ? "" : "?" + options.collect{ |k,v| "#{k}=#{v}" }.join("&")
|
121
|
+
options = (options.empty? ? "" : "?" + options.collect{ |k,v| "#{k}=#{v}" }.join("&"))
|
122
122
|
end
|
123
123
|
|
124
124
|
#
|
data/lib/abstracted/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: abstracted
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Walther H Diechmann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-09-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -581,7 +581,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
581
581
|
version: '0'
|
582
582
|
requirements: []
|
583
583
|
rubyforge_project:
|
584
|
-
rubygems_version: 2.
|
584
|
+
rubygems_version: 2.2.2
|
585
585
|
signing_key:
|
586
586
|
specification_version: 4
|
587
587
|
summary: Abstracted DRY's up your controllers totally
|