I am using a helper method to generate my search result listings:
def search_result_name(result)
case result
when Term
“
#{result.title}
Filed under: Terms”
when Article
“
#{result.title}
Filed under: Articles”
else
result.to_s
end
end
This works perfectly, but I hit a wall when I try to include a link
in the above method. I try using a link_to helper inside a string
interpolation block but Rails does not parse the helper.
Any ideas?
I figured it out. All I needed was to move my case statements to my
view and it works (duh!)
On Tue, May 01, 2007 at 09:15:47PM +0200, Steven G. wrote:
else
result.to_s
end
end
This works perfectly, but I hit a wall when I try to include a link
in the above method. I try using a link_to helper inside a string
interpolation block but Rails does not parse the helper.
strange, I often use link_to in helpers, i.e. to embed links in list
elements:
def navsec_link(text, link, options = {})
“
#{link_to text, link, options}”
end
Jens
–
Jens Krämer
webit! Gesellschaft für neue Medien mbH
Schnorrstraße 76 | 01069 Dresden
Telefon +49 351 46766-0 | Telefax +49 351 46766-66
[email protected] | www.webit.de
Amtsgericht Dresden | HRB 15422
GF Sven Haubold, Hagen Malessa
Ahhhh… i see now.
My syntax was off. I tried shoving ERB code into the string
interpolation, silly man that I am.
Still, I almost prefer this in my view since I am only using results
like this in one template.
Thanks for the pointer though, will definitely prove useful for
something else.