Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RoR - make links clickable that show up in a user comment

I am looking for a Ruby script that takes a piece of text, and makes any links click-able that show up in it... Does anyone have something like this? For example, if I wrote a comment and said "Come check out my site at http://www.example.com", then the link would be click-able like an html tag.

Thanks,

Josh

like image 433
Josh Avatar asked Dec 01 '25 09:12

Josh


1 Answers

Rails has a View helper called auto_link, e.g.:

<%= auto_link("Please visit my site: http://www.example.org/") %>

would produce:

Please visit my site: <a href="http://www.example.org/">http://www.example.org/</a>

Update: You can find more information about it here.

like image 124
Tomas Markauskas Avatar answered Dec 03 '25 23:12

Tomas Markauskas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!