Created
March 26, 2012 15:40
-
-
Save kvirani/2206046 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def url_valid | |
url = URI.parse(get_linkedin_profile) | |
unless %w( http https ).include?(url.scheme) && (url.hostname.include? "linkedin") && !url.path.blank? | |
errors.add(:detail, "Please Enter a Valid Linkedin Profile URL") | |
end | |
rescue URI::InvalidURIError => e | |
errors.add(:detail, "Please Enter a Valid Linkedin Profile URL") | |
end | |
#This method works fine but How can I better handle invalid string values like linkedin_url = ">>>>>" ? | |
# Now such string gives me this error instead of error message | |
URI::InvalidURIError in UsersController#action | |
bad URI(is not URI?): >>>>>>>>>>>>>>>>>> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment