Skip to content

Instantly share code, notes, and snippets.

@rpheath
Created August 6, 2012 18:30
Show Gist options
  • Save rpheath/3277353 to your computer and use it in GitHub Desktop.
Save rpheath/3277353 to your computer and use it in GitHub Desktop.
Link Validation
class Article < ActiveRecord::Base
# ...
def embedded_links
self.body_html.scan(/<a.+?href="(.+?)".+?/) if body_html
end
def has_links?
self.embedded_links.flatten.present?
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment