Skip to content

Instantly share code, notes, and snippets.

@meltzerj
Created April 27, 2011 23:34
Show Gist options
  • Select an option

  • Save meltzerj/945472 to your computer and use it in GitHub Desktop.

Select an option

Save meltzerj/945472 to your computer and use it in GitHub Desktop.
VALID_URLS = [
/^(?:http:\/\/)?(?:www\.)?youtube\.com\/watch\?v=([a-zA-Z0-9_-]*)/,
/^(?:http:\/\/)?(?:www\.)?vimeo\.com\/(\d+)/,
/^(?:http:\/\/)?(?:www\.)?soundcloud\.com\/(\w+)/,
nil
]
validates :link, :uniqueness => true,
:format => { :with => Regexp.new(VALID_URLS.join('|')) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment