Skip to content

Instantly share code, notes, and snippets.

View tranngocsam's full-sized avatar

Tran Ngoc Sam tranngocsam

View GitHub Profile
@tranngocsam
tranngocsam / gist:3744205
Created September 18, 2012 16:42
Carrierwave validate remote url - Tested with v0.5.8
#############################################
###uri_validator file:
#############################################
require 'net/http'
# Thanks Ilya! http://www.igvita.com/2006/09/07/validating-url-in-ruby-on-rails/
# Original credits: http://blog.inquirylabs.com/2006/04/13/simple-uri-validation/
# HTTP Codes: http://www.ruby-doc.org/stdlib/libdoc/net/http/rdoc/classes/Net/HTTPResponse.html
class UriValidator < ActiveModel::EachValidator