better_record 0.13.0 → 0.13.1
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: 26ce3d168b954c9b73c86f86910bf9a2e39bbe9ccfef04a424f63aa8406998af
|
|
4
|
+
data.tar.gz: 78df16dd5a0a432d50faa188adfb9fc069ed12f5d05a26ae0d5c242b291ad0d9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7ae0b4f8df3038a0e1f84712b9b9d9765768af2cc4774165c80e912cf4c3f1fdca2fee20dcbf939620b8ea6261bccedde5d73ced320e0000190cf2a6b738b19d
|
|
7
|
+
data.tar.gz: 0e1845dbd6c18909038615f851f51ebaa64b3d3def80fad6209b4c69aada3d5c15a33e88a8fcf943f2a7545b04f0b33959c0eeb7fb54d500855012a6525f89e1
|
|
@@ -33,7 +33,7 @@ module BetterRecord
|
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
def self.user_type
|
|
36
|
-
self.user ? BetterRecord::PolymorphicOverride.polymorphic_value(self.user.class) : 'NULL'
|
|
36
|
+
self.user ? "'#{BetterRecord::PolymorphicOverride.polymorphic_value(self.user.class)}'" : 'NULL'
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
def self.user_id
|
|
@@ -98,25 +98,32 @@ module BetterRecord
|
|
|
98
98
|
|
|
99
99
|
def transaction(*args)
|
|
100
100
|
super(*args) do
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
101
|
+
if BetterRecord::Current.user
|
|
102
|
+
ActiveRecord::Base.connection.execute <<-SQL
|
|
103
|
+
CREATE TEMP TABLE IF NOT EXISTS
|
|
104
|
+
"_app_user" (user_id integer, user_type text, ip_address inet);
|
|
105
|
+
|
|
106
|
+
UPDATE
|
|
107
|
+
_app_user
|
|
108
|
+
SET
|
|
109
|
+
user_id=#{current_user_id},
|
|
110
|
+
user_type=#{current_user_type},
|
|
111
|
+
ip_address=#{current_user_ip};
|
|
112
|
+
|
|
113
|
+
INSERT INTO
|
|
114
|
+
_app_user (user_id, user_type, ip_address)
|
|
115
|
+
SELECT
|
|
116
|
+
#{current_user_id},
|
|
117
|
+
#{current_user_type},
|
|
118
|
+
#{current_user_ip}
|
|
119
|
+
WHERE NOT EXISTS (SELECT * FROM _app_user);
|
|
120
|
+
SQL
|
|
121
|
+
else
|
|
122
|
+
ActiveRecord::Base.connection.execute <<-SQL
|
|
123
|
+
CREATE TEMP TABLE IF NOT EXISTS
|
|
124
|
+
"_app_user" (user_id integer, user_type text, ip_address inet);
|
|
125
|
+
SQL
|
|
126
|
+
end
|
|
120
127
|
|
|
121
128
|
yield
|
|
122
129
|
end
|