class SocialLink < ActiveRecord::Base belongs_to :profile has_one :user, through: :profile def to_icon case self.url when /twitter\.com/, /x\.com/ social_icon = "" when /dscvr.one/ social_icon = "" else social_icon = "🌐" end end def to_url if self.url.scan(/https?:\/\//).empty? "https://#{self.url}" else self.url end end end