RAILS link_to external site, url is attribute of user table, like: @users.website

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'

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)