I am creating a Twitter clone in Ruby On Rails, how do I code it so that the '@...''s in the 'tweets' turn into links?

ruby, ruby-on-rails

Solution

def linkup_mentions_and_hashtags(text)    
  text.gsub!(/@([\w]+)(\W)?/, '<a href="http://twitter.com/\1">@\1</a>\2')
  text.gsub!(/#([\w]+)(\W)?/, '<a href="http://twitter.com/search?q=%23\1">#\1</a>\2')
  text
end

I found this example here: http://github.com/jnunemaker/twitter-app

The link to the helper method: http://github.com/jnunemaker/twitter-app/blob/master/app/helpers/statuses_helper.rb

Problem

I am somewhat of a Rails newbie so bear with me, I have most of the application figured out except for this one part.

Original source