validate url rails code example Example: rails check if a URL is valid require 'uri' url =~ URI::regexp # => 0 if it match, nil if not