Convert plain text URLs to HTML hyperlinks in Ruby on Rails?
See rinku gem, which is apparently faster and more accurate than autolink gem
Rails 3
Use the provided helper method called auto_link
, which is part of ActionPack.
<%=h auto_link(@my_object.description) %>
Rails 4
Auto-linking has been removed from Rails and has been made into the rails_autolink
gem.
require 'rails_autolink'
auto_link("Go to http://www.rubyonrails.org and say hello to [email protected]")
# => "Go to <a href=\"http://www.rubyonrails.org\">http://www.rubyonrails.org</a> and
# say hello to <a href=\"mailto:[email protected]\">[email protected]</a>"