check if vin is changed to prevent loops

This commit is contained in:
2026-03-26 07:20:19 -04:00
parent 89dc3cd5f4
commit 44bfb69e22

View File

@@ -17,7 +17,7 @@ class Vehicle < ApplicationRecord
validates :customer, presence: true validates :customer, presence: true
validates :vin, presence: true, uniqueness: true validates :vin, presence: true, uniqueness: true
before_validation :normalize_vin before_validation :normalize_vin
after_commit :enqueue_vin_decode after_commit :enqueue_vin_decode, if: :saved_change_to_vin?
acts_as_searchable columns: %w[vin make model year], scope: ->(_context) { all }, date_column: :updated_at acts_as_searchable columns: %w[vin make model year], scope: ->(_context) { all }, date_column: :updated_at
acts_as_event :title => Proc.new {|o| "#{o.to_s}"}, acts_as_event :title => Proc.new {|o| "#{o.to_s}"},
:url => Proc.new {|o| { :controller => 'vehicles', :action => 'show', :id => o.id} }, :url => Proc.new {|o| { :controller => 'vehicles', :action => 'show', :id => o.id} },