Skip to content

Commit

Permalink
Save uuid__old for the transition period
Browse files Browse the repository at this point in the history
  • Loading branch information
gsmetal committed Feb 7, 2024
1 parent 097099f commit 9fad44b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/uuidable/active_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ def uuidable(as_param: true) # rubocop:disable Metrics/AbcSize, Metrics/Cyclomat
end
end

after_initialize { self.uuid = Uuidable.generate_uuid if attributes.keys.include?('uuid') && uuid.blank? }
after_initialize do
self.uuid = Uuidable.generate_uuid if attributes.keys.include?('uuid') && uuid.blank?
self.uuid__old = uuid if respond_to?(:uuid__old)
end

validates :uuid, presence: true, uniqueness: true, if: :uuid_changed?

if as_param
Expand Down

0 comments on commit 9fad44b

Please sign in to comment.