我想将字符串中的 url 转换为可用的 url。例如:str = "你好,这是雅虎的链接:http ://www.yahoo.com "
//in the view i have
<%= parse_description(r[:description]) %>
//in helper, i am splitting each word in the string and verifying if i have a string which
// contains http, if http is present then i am using link_to to make it a valid url:
def parse_description(str)
s = ""
str.split.each do |w|
a = w.include?("http") ? (link_to nil,"#{w}") : w
s += "#{a} "
end
end
一旦字符串返回到视图中,链接就不可点击了。我在做什么错?