Twitter gem user timeline link_to helper for hashes

Hi all,
I just installed the Twitter gem and created a partial where I can publish my latest tweets. Because the output

is plain text I created an application helper which should replace the hash tags into some links.

First of all is this a convenient way or is there even a better solution like build in link to helper or something like that (couldn’t find anything so far).

My second question is regards my helper function. I had a solution which was working but the code sucked:

def change_hashes

hashes = text.scan(/#\d*\w*/)

hashes.each do |hash|

text = sanitize(text.gsub(hash, link_to(hash, “!/search/#{hash.sub(/#/, “%23”)}”)))


return text


So I refactored it into this:

def change_hashes(text)

text.gsub(/#\d*\w*/) { |s| text.sub(s, link_to(s, “!/search/#{s.sub(/#/, “%23”)}”)) }


The problem is that if I the tweet contains more than one hash the whole tweet is being duplicated. Maybe someone can pinpoint me into the right direction?