Over my lunch today I finally had an opportunity to use something I learned yesterday reading Dan Croak’s “gsub with a block” post on the Thoughtbot blog.
I use the twitter gem and just display my last status on my personal homepage at JasonMeridth.com. I didn’t want to hand out my username and password so all I do is encapsulate the twitter piece in a module called TwitterHelper and put it into my app/helpers/ folder in my Rails application:
| |
and then in my view I just call:
| |
The important part of code to look at is:
| |
This code will wrap any strings that start with http:// with an html href.