Skip to content

Commit

Permalink
Hotfix to set record_type after auth_merge #746
Browse files Browse the repository at this point in the history
  • Loading branch information
HirschSt committed Mar 5, 2019
1 parent 39282d9 commit ad2cb73
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/authority_merge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def migrate_to_id(new_id)
refs << self.send(s)
end
refs.flatten.each do |s|
record_type = s.has_attribute?(:record_type) ? s.record_type : nil
klass = s.marc.class
s.marc.change_authority_links(self, new_model)

Expand All @@ -61,7 +62,7 @@ def migrate_to_id(new_id)

This comment has been minimized.

Copy link
@xhero

xhero Mar 11, 2019

Contributor

Found the problem!

new_marc = klass.new(s.marc.to_marc)

The marc source is tied to the record type, so when creating a new one record type must be passed along (the snipped is copied from the marc controller):

      if @item.respond_to?(:record_type)
        new_marc = dyna_marc_class.new(old_item.marc.to_marc, @item.record_type)
      else
        new_marc = dyna_marc_class.new(old_item.marc.to_marc)
      end
# set marc and save
s.marc = new_marc

s.record_type = record_type if record_type
s.paper_trail_event = "#{self.class} change id from #{self.id} to #{new_id}"
s.save
end
Expand Down

1 comment on commit ad2cb73

@HirschSt
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xhero I'm not sure where the record_type is lost exactly, but we can look for this in calmer mood after the hotfix

Please sign in to comment.