I had the same issue which caused some problems as the application I am working on has global toast messages that come up for errors such as 404 on ajax calls.
That being the case, I made this patch. You can certainly do more. It would be a good idea, for example, to change how the javascript works, but this monkey patch is the smallest change I could make to the code and still get the required functionality. Please note, HTTP 204 is used because the ClientSideValidations gem expects all HTTP 200 (very specifically 200) responses to be validation failed responses and, so, couldn't be reused without also changing the javascript.
app/config/initializers/client_side_validations.rb
ClientSideValidations::Config.disabled_validators = []
# Monkey Patch
# Guranatee uniqueness middleware is fully loaded
::ClientSideValidations::Middleware::Uniqueness
module ClientSideValidations
module Middleware
class Uniqueness
def response
begin
if unique?
self.status = 204 # changed from 404
self.body = '' # changed from true
else
self.status = 200
self.body = 'false'
end
rescue NotValidatable
self.status = 500
self.body = ''
end
super
end
end
end
end