In a Rails 3 view, how do I detect an URL in a display string and format it as a link to that URL? -


i have user generated comments on site. if user adds url in comment, i'd formatted link , link url. how do that?

rails has auto_link text helper.

auto_link("go http://www.rubyonrails.org , hello david@loudthinking.com") # => "go <a href=\"http://www.rubyonrails.org\">http://www.rubyonrails.org</a> , #     hello <a href=\"mailto:david@loudthinking.com\">david@loudthinking.com</a>"  auto_link("visit http://www.loudthinking.com/ or e-mail david@loudthinking.com", :link => :urls) # => "visit <a href=\"http://www.loudthinking.com/\">http://www.loudthinking.com/</a> #     or e-mail david@loudthinking.com" 

Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -