effective_resources 1.18.10 → 1.19.0
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ee4ff2d3193e327ddaa6fd457d83df4342e1ccfd1a5a0d2d06525ee5e8b5ce3
|
4
|
+
data.tar.gz: 63c5eebe27c1f4a49fba71dd2e1b69a92ce73faa35c915f53f77b4fca8dc8beb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d6f2209d606a8e800f9d9b715b06dfbe1d230f73dd429728257d2f7b2876211bba08a5111cf992a9ed20c92f8d320bf62a2cae994c550d8e27b354e4ea602c3d
|
7
|
+
data.tar.gz: 7d78f999628f819a663debe59ffd1799c1b8caeaafb264e4fe986b90f23a573d63d019612e83b455c75fb2741510367f706015b9c5587b0b24b731e3b398286a
|
@@ -29,44 +29,43 @@ module Effective
|
|
29
29
|
end
|
30
30
|
|
31
31
|
success = false
|
32
|
+
exception = nil
|
32
33
|
|
33
|
-
|
34
|
-
|
35
|
-
|
34
|
+
begin
|
35
|
+
ActiveRecord::Base.transaction do
|
36
|
+
EffectiveResources.transaction(resource) do
|
37
|
+
run_callbacks(:resource_before_save)
|
36
38
|
|
37
|
-
|
38
|
-
|
39
|
-
|
39
|
+
if resource.public_send("#{save_action}!") == false
|
40
|
+
raise Effective::ActionFailed.new("failed to #{action}")
|
41
|
+
end
|
40
42
|
|
41
|
-
|
43
|
+
yield if block_given?
|
42
44
|
|
43
|
-
|
45
|
+
run_callbacks(:resource_after_save)
|
44
46
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
Rails.logger.info " \e[31m\e[1mFAILED\e[0m\e[22m" # bold red
|
49
|
-
Rails.logger.info " Unable to #{action} #{resource} - #{e.class} #{e}"
|
50
|
-
e.backtrace.first(5).each { |line| Rails.logger.info(' ' + line) }
|
47
|
+
success = true
|
48
|
+
rescue Effective::ActionFailed => e
|
49
|
+
exception = e # Dont rollback
|
51
50
|
end
|
51
|
+
end
|
52
|
+
rescue => e
|
53
|
+
exception = e
|
54
|
+
end
|
52
55
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
+
if exception.present?
|
57
|
+
Rails.logger.info " \e[31m\e[1mFAILED\e[0m\e[22m" # bold red
|
58
|
+
Rails.logger.info " Unable to #{action} #{resource} - #{e.class} #{e}"
|
59
|
+
exception.backtrace.first(5).each { |line| Rails.logger.info(' ' + line) }
|
56
60
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
when ActiveRecord::RecordInvalid, RuntimeError
|
66
|
-
raise(ActiveRecord::Rollback) # This is a soft error, we want to display the flash message to user
|
67
|
-
else
|
68
|
-
raise(e) # This is a real error that should be sent to 500. Client should not see the message.
|
69
|
-
end
|
61
|
+
if resource.respond_to?(:restore_attributes) && resource.persisted?
|
62
|
+
resource.restore_attributes(['status', 'state'])
|
63
|
+
end
|
64
|
+
|
65
|
+
flash.now[:danger] = resource_flash(:danger, resource, action, e: e)
|
66
|
+
|
67
|
+
if exception.kind_of?(ActiveRecord::StaleObjectError)
|
68
|
+
flash.now[:danger] = "#{flash.now[:danger]} <a href='#', class='alert-link' onclick='window.location.reload(true); return false;'>reload page and try again</a>"
|
70
69
|
end
|
71
70
|
end
|
72
71
|
|
data/lib/effective_resources.rb
CHANGED
@@ -87,10 +87,7 @@ module EffectiveResources
|
|
87
87
|
end
|
88
88
|
|
89
89
|
def self.transaction(resource = nil, &block)
|
90
|
-
|
91
|
-
raise('unable to determine transaction class') unless connection.present?
|
92
|
-
|
93
|
-
connection.transaction { yield }
|
90
|
+
resource.class.transaction { yield }
|
94
91
|
end
|
95
92
|
|
96
93
|
# Used by streaming CSV export in datatables
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_resources
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.19.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-09-
|
11
|
+
date: 2022-09-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|