Skip to content

Commit eb98cc5

Browse files
committed
fix for Rails 5.2 fixes #22
- the actual fix is the use of saved_changes, removal of the lambda argument is just for simplification - https://www.ombulabs.com/blog/rails/upgrades/active-record-5-1-api-changes.html
1 parent 61692b3 commit eb98cc5

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

app/models/issue_supply_item.rb

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,24 @@ class IssueSupplyItem < ActiveRecord::Base
99
includes(:supply_item).order("#{SupplyItem.table_name}.name ASC")
1010
}
1111

12-
after_destroy ->(isi){
13-
RedmineSupply::RecordIssueSupplyItemChange.(isi.issue,
14-
isi.supply_item,
15-
isi.quantity)
12+
after_destroy ->{
13+
RedmineSupply::RecordIssueSupplyItemChange.(issue,
14+
supply_item,
15+
quantity)
1616
}
1717

18-
after_create ->(isi){
19-
RedmineSupply::RecordIssueSupplyItemChange.(isi.issue,
20-
isi.supply_item,
21-
-1 * isi.quantity)
18+
after_create ->{
19+
RedmineSupply::RecordIssueSupplyItemChange.(issue,
20+
supply_item,
21+
-1 * quantity)
2222
}
2323

24-
after_update ->(isi){
25-
if isi.quantity_was != isi.quantity
26-
RedmineSupply::RecordIssueSupplyItemChange.(isi.issue,
27-
isi.supply_item,
28-
isi.quantity_was - isi.quantity)
24+
after_update ->{
25+
if changes = saved_changes['quantity']
26+
quantity_was, quantity = changes
27+
RedmineSupply::RecordIssueSupplyItemChange.(issue,
28+
supply_item,
29+
quantity_was - quantity)
2930
end
3031
}
3132

0 commit comments

Comments
 (0)