Skip to content

Instantly share code, notes, and snippets.

@sstarr
Created July 8, 2014 21:15
Show Gist options
  • Save sstarr/d8c22575ad38e6c23c0f to your computer and use it in GitHub Desktop.
Save sstarr/d8c22575ad38e6c23c0f to your computer and use it in GitHub Desktop.
class Profile < ActiveRecord::Base
# ...
def format_twitter_url
unless self.twitter_url.blank? || self.twitter_url[/^https?:\/\//]
if self.twitter_url[/twitter\.com/i]
self.twitter_url = 'http://' + self.twitter_url
else
self.twitter_url = "https://twitter.com/#{self.twitter_url.sub(/@/, '')}"
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment