Skip to content

Instantly share code, notes, and snippets.

@bmaland
Created November 18, 2010 18:58
Show Gist options
  • Select an option

  • Save bmaland/705429 to your computer and use it in GitHub Desktop.

Select an option

Save bmaland/705429 to your computer and use it in GitHub Desktop.
# Allow the metal piece to run in isolation
require(File.dirname(__FILE__) + "/../../config/environment") unless defined?(Rails)
# Drop-in replacement for the LiveValidations controller that ships with
# live-validations.
class ValidationPoller
def self.call(env)
if env["PATH_INFO"] =~ /^\/live_validations\/uniqueness/
params = HashWithIndifferentAccess.new(Rack::Request.new(env).params)
responder = LiveValidations.current_adapter.validation_responses[:uniqueness]
[200, {"Content-Type" => "text/html"}, [responder.respond(params).to_s]]
else
[404, {"Content-Type" => "text/html"}, ["Not Found"]]
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment