Scaping quotes and backslashes (I hope you understand my pro

Can you maybe boil it down to a smaller example? The only thing I can think of is maybe it's un-escaping the characters too many times, or not enough times.

If I hardcode the anchor tag in my rhtml file as follows it works fine for me. I did have to dispense with the \\ though. However, I get the impression you were not hardcoding this in your view. If your still having trouble with it, post your controller and view code.

<a href="javascript: void(0);" class="defns" onmouseover="coolTip('&lt;a href=\'/wiki/show_appears?value=Fidel+Castro&amp;name=primaryCharacter\' &gt;Appears...&lt;/a&gt;',STICKY, MOUSEOFF);" onmouseout="nd();">Hello</a>

-Paul

Ok, I understand you need to change it programmatically. I added the \\ back in, put it in a string assigned to an instance variable and did a simple render in the view. It seems to work just fine for me. Here is the string in my controller:

@testvar = '<a href="javascript: void(0);" class="defns" onmouseover="coolTip(\'&lt;a href=\\\'/wiki/show_appears?value=Fidel+Castro&amp;name=primaryCharacter\\\' &gt;Appears...&lt;/a&gt;\',STICKY, MOUSEOFF);" onmouseout="nd();">Hello</a>'

Here is the rhtml code:

<%= @testvar %>

And here is the html as it appears in the browser when I do view source:

<a href="javascript: void(0);" class="defns" onmouseover="coolTip('&lt;a href=\'/wiki/show_appears?value=Fidel+Castro&amp;name=primaryCharacter\' &gt;Appears...&lt;/a&gt;',STICKY, MOUSEOFF);" onmouseout="nd();">Hello</a>

By the way I am using Firefox 1.0.5.9 and IE 6.

-Paul

I was using rails v1.1.2 but I just upgraded to v1.1.6 and it still works fine for me. I am using Ruby v1.8.4 on a Windows XP box. I guess at this point I would check the development.log to see if there is something in there that might give you a clue. I suppose it's also possible a plug-in might be causing the problem Otherwise, I think your only recourse is to rebuild the environment by installing a clean version of ruby on rails. Don't install any plug-ins and give it another shot.

-Paul

PS:<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />

Damaris - if you can post an example of working code that fails I think we can figure this out. Show me a real code fragment, something I can recreate on my end.

Thanks, Paul

It seems we need to add another set of double backslashes to get the desired results. I don't understand this as the documentation says that on a single quoted string that a double backslash converts to a single backslash.

puts "ERG" + varTest1.gsub!('hola', '\\\\\'') --> ERG\'

-Paul

Glad to see it fixed the problem. I've added this to my growing list of gotcha's. :slight_smile: