mirror of
https://github.com/internetee/registry.git
synced 2025-07-20 17:55:55 +02:00
Fix ignored attributes on history models
Concern method #all_versions_for(ids, time) tried to create model instance from history and raises an exception when in history object there are some columns which are ignored in model at the moment. This patch removes ignored columns from data used to create a new inctance. See #1489
This commit is contained in:
parent
7d86362c55
commit
3d424e3dd0
1 changed files with 2 additions and 1 deletions
|
@ -61,7 +61,8 @@ module Versions
|
||||||
preceding(time + 1, true).
|
preceding(time + 1, true).
|
||||||
select("distinct on (item_id) #{ver_klass.table_name}.*").
|
select("distinct on (item_id) #{ver_klass.table_name}.*").
|
||||||
map do |ver|
|
map do |ver|
|
||||||
o = new(ver.object)
|
ignored_columns = ver.item_type.constantize&.ignored_columns
|
||||||
|
o = new(ver.object&.except!(*ignored_columns))
|
||||||
o.version_loader = ver
|
o.version_loader = ver
|
||||||
ver.object_changes.to_h.each { |k, v| o.public_send("#{k}=", v[-1]) }
|
ver.object_changes.to_h.each { |k, v| o.public_send("#{k}=", v[-1]) }
|
||||||
o
|
o
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue