Skip to content

Instantly share code, notes, and snippets.

@benbonnet
Created April 7, 2014 14:38
Show Gist options
  • Save benbonnet/10021544 to your computer and use it in GitHub Desktop.
Save benbonnet/10021544 to your computer and use it in GitHub Desktop.
before_validation :smart_url_field
protected
def smart_url_field
["website","facebook_url","twitter_url","soundcloud_url"].each do |check|
self["#{check}"] = "http://#{self["#{check}"]}" unless self["#{check}"][/\Ahttp:\/\//] || self["#{check}"][/\Ahttps:\/\//] || !self["#{check}"].presence
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment