You can prepend url with protocol if it’s absent:
module UrlHelper
def url_with_protocol(url)
/^http/i.match(url) ? url : "http://#{url}"
end
end
And then:
link_to @user.site, url_with_protocol(@user.url), :target => '_blank'
You can prepend url with protocol if it’s absent:
module UrlHelper
def url_with_protocol(url)
/^http/i.match(url) ? url : "http://#{url}"
end
end
And then:
link_to @user.site, url_with_protocol(@user.url), :target => '_blank'