Forum: Ruby on Rails escape character problem

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Sunny B. (Guest)
on 2008-12-28 09:21
Hi, i need to construct a link  as following

  "<a href=\"#{CONFIG['URLS']['Xyz']}\#{url}\"#{tag_options}>#{name ||
url}</a>"

  But here due to escape character #{url} not give actual value it
treated as a string. how to solve this ?
if i do
"<a href=\"#{CONFIG['URLS']['xyz']}\\#{url}\"#{tag_options}>#{name ||
url}</a>"
then #{url} gives me proper value but link is wron constructed?

 please suggest me solution.
Ken W. (Guest)
on 2008-12-28 10:52
Sunny B. wrote:
> Hi, i need to construct a link  as following
>
>   "<a href=\"#{CONFIG['URLS']['Xyz']}\#{url}\"#{tag_options}>#{name ||
> url}</a>"
>
>   But here due to escape character #{url} not give actual value it
> treated as a string. how to solve this ?
> if i do
> "<a href=\"#{CONFIG['URLS']['xyz']}\\#{url}\"#{tag_options}>#{name ||
> url}</a>"
> then #{url} gives me proper value but link is wron constructed?
>
>  please suggest me solution.

Not sure, but there is an "h(...)" function available to 'escape' code
the enclosed content. Have you tried it?
This topic is locked and can not be replied to.