effective_resources 1.19.0 → 2.0.0
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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f9da0a46c6938d58b83a1da33cf0a198c8f4f53f7c3bb4b96ee5467160c06370
|
4
|
+
data.tar.gz: 6435ce69271ba313f1d02642d16ad24791cd4c2ea99e14be06782ceb4cc409e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b35a6f53cd730eec70f2010332cbfd44c7e311b4341cf033b2b490069341b0e9fdad5bd607209b6ef63e1e9695dfcd5490b72d14a293aceed31159cacd2a30c9
|
7
|
+
data.tar.gz: bea48fa8d635bbed0d2786b52c70b09a7e35629177bcda6f5218f1d7c83db5c1fe964f88243468d22b2753ee0a74223b6d3e91d47e67e8f5320a202bdb8942f5
|
@@ -33,7 +33,7 @@ module Effective
|
|
33
33
|
|
34
34
|
begin
|
35
35
|
ActiveRecord::Base.transaction do
|
36
|
-
|
36
|
+
resource.transaction do
|
37
37
|
run_callbacks(:resource_before_save)
|
38
38
|
|
39
39
|
if resource.public_send("#{save_action}!") == false
|
@@ -55,14 +55,14 @@ module Effective
|
|
55
55
|
|
56
56
|
if exception.present?
|
57
57
|
Rails.logger.info " \e[31m\e[1mFAILED\e[0m\e[22m" # bold red
|
58
|
-
Rails.logger.info " Unable to #{action} #{resource} - #{
|
58
|
+
Rails.logger.info " Unable to #{action} #{resource} - #{exception.class} #{exception}"
|
59
59
|
exception.backtrace.first(5).each { |line| Rails.logger.info(' ' + line) }
|
60
60
|
|
61
61
|
if resource.respond_to?(:restore_attributes) && resource.persisted?
|
62
62
|
resource.restore_attributes(['status', 'state'])
|
63
63
|
end
|
64
64
|
|
65
|
-
flash.now[:danger] = resource_flash(:danger, resource, action, e:
|
65
|
+
flash.now[:danger] = resource_flash(:danger, resource, action, e: exception)
|
66
66
|
|
67
67
|
if exception.kind_of?(ActiveRecord::StaleObjectError)
|
68
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>"
|
@@ -29,9 +29,11 @@ module ActsAsTokened
|
|
29
29
|
return super unless args.length == 1
|
30
30
|
return super if block_given?
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
|
32
|
+
reloading = instance_variable_get(:@_effective_reloading)
|
33
|
+
reloading ||= self.class.instance_variable_get(:@_effective_reloading)
|
34
|
+
reloading ||= klass.instance_variable_get(:@_effective_reloading) if respond_to?(:klass)
|
35
|
+
|
36
|
+
return find_by_id(args.first) if reloading
|
35
37
|
|
36
38
|
find_by_token(args.first) || raise(::ActiveRecord::RecordNotFound.new("Couldn't find #{name} with 'token'=#{args.first}"))
|
37
39
|
end
|
data/lib/effective_resources.rb
CHANGED
@@ -86,10 +86,6 @@ module EffectiveResources
|
|
86
86
|
klass
|
87
87
|
end
|
88
88
|
|
89
|
-
def self.transaction(resource = nil, &block)
|
90
|
-
resource.class.transaction { yield }
|
91
|
-
end
|
92
|
-
|
93
89
|
# Used by streaming CSV export in datatables
|
94
90
|
def self.with_resource_enumerator(&block)
|
95
91
|
raise('expected a block') unless block_given?
|