Validate URIs by Pinging the Server
require 'open-uri' class ActiveRecord::Base def self.validates_uri_existence_of(*attr_names) configuration = { :message => "is not a valid web address" } configuration.update(attr_names.pop) if attr_names.last.is_a?(Hash) validates_each attr_names do |m, a, v| begin # Try to open the URI open v rescue # Report the error if it throws an exception m.errors.add(a, configuration[:message]) end end end end
Details on my blog.