mirror of
https://github.com/internetee/registry.git
synced 2025-07-22 18:56:05 +02:00
Solve both sides of the missing fields bug, not only one
This commit is contained in:
parent
cec05c3943
commit
a82db7a67a
7 changed files with 21 additions and 11 deletions
|
@ -1,10 +1,15 @@
|
|||
module ObjectVersionsHelper
|
||||
def attach_existing_fields(version, new_object)
|
||||
version.object_changes.to_h.each do |k, v|
|
||||
method_name = "#{k}=".to_sym
|
||||
version.object_changes.to_h.each do |key, value|
|
||||
method_name = "#{key}=".to_sym
|
||||
if new_object.respond_to?(method_name)
|
||||
new_object.public_send(method_name, v.last)
|
||||
new_object.public_send(method_name, value.last)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def only_present_fields(version, model)
|
||||
field_names = model.column_names
|
||||
version.object.to_h.select { |key, _value| field_names.include?(key) }
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue