web47core 0.7.6 → 0.7.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/app/models/concerns/standard_model.rb +10 -8
- data/lib/web47core/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 13c5bfc15e45ddc49167d2f71c698abe48c22d7b974ba18096509bc9d9288118
|
4
|
+
data.tar.gz: a8f8f18537be2bf61f7ce7e7bae6b1b552f9dfd51314c250be663971bc355855
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c988580b2939046e514b84e517998a36e2d6f87ed4b9a2388f3ab3f04f55dec4c9cf6cb2215407f92d5ea49999f631c4e02ad5a373ae293e53ca37307e8fd91f
|
7
|
+
data.tar.gz: 84291d6a8153f65b925e9f280b7152f3b2396520fee0c87f40f382f6a223d5bf0e927e3a85e9838ebc460939280974b54bbed4cac23ceba0957301eee311e4cc
|
@@ -22,8 +22,8 @@ module StandardModel
|
|
22
22
|
#
|
23
23
|
# Relationships
|
24
24
|
#
|
25
|
-
belongs_to :last_modified_by,
|
26
|
-
belongs_to :created_by,
|
25
|
+
belongs_to :last_modified_by, polymorphic: true, dependent: :nullify, optional: true
|
26
|
+
belongs_to :created_by, polymorphic: true, dependent: :nullify, optional: true
|
27
27
|
has_many Web47core::Config.audit_model_log_symbol, dependent: :nullify, inverse_of: :model
|
28
28
|
#
|
29
29
|
# Callbacks
|
@@ -98,9 +98,10 @@ module StandardModel
|
|
98
98
|
# Record the creation with this user
|
99
99
|
#
|
100
100
|
def create_and_log(user, attributes)
|
101
|
-
attributes[:last_modified_by_id] = user.id
|
102
|
-
attributes[:created_by_id] = user.id
|
103
101
|
model = create(attributes)
|
102
|
+
model.last_modified_by = user
|
103
|
+
model.created_by = user
|
104
|
+
model.save
|
104
105
|
log_change(user, model, attributes) if model.valid?
|
105
106
|
model
|
106
107
|
end
|
@@ -109,9 +110,10 @@ module StandardModel
|
|
109
110
|
# Record the creation with this user
|
110
111
|
#
|
111
112
|
def create_and_log!(user, attributes)
|
112
|
-
attributes[:last_modified_by_id] = user.id
|
113
|
-
attributes[:created_by_id] = user.id
|
114
113
|
model = create!(attributes)
|
114
|
+
model.last_modified_by = user
|
115
|
+
model.created_by = user
|
116
|
+
model.save!
|
115
117
|
log_change(user, model, attributes)
|
116
118
|
model
|
117
119
|
end
|
@@ -209,7 +211,7 @@ module StandardModel
|
|
209
211
|
return self if attributes.blank?
|
210
212
|
|
211
213
|
action = audit_action
|
212
|
-
|
214
|
+
self.last_modified_by = user
|
213
215
|
result = update(attributes)
|
214
216
|
log_change(user, attributes, action) if valid?
|
215
217
|
result
|
@@ -224,7 +226,7 @@ module StandardModel
|
|
224
226
|
return self if attributes.blank?
|
225
227
|
|
226
228
|
action = audit_action
|
227
|
-
|
229
|
+
self.last_modified_by = user
|
228
230
|
result = update!(attributes)
|
229
231
|
log_change(user, attributes, action)
|
230
232
|
result
|
data/lib/web47core/version.rb
CHANGED