From: Edmond Kachale Date: 2011-02-15T22:11:56+09:00 Subject: Re: Assign Ruby string value to Javascrip variable? --90e6ba6e8a229031c6049c51e8f3 Content-Type: text/plain; charset=ISO-8859-1 2011/2/15 Lorenzo Brito Morales > yes you can, but where you are doing it, in the view.js.erb file? > I expect this to work pretty will even in view.html.erb. As I write, I am able to do this without problems as follows: var userName = "<%= @user.name%>"; 2011/2/15 cz Is it possible to assign a ruby string value to a javascript variable? I can display the ruby value on the browser. It looks fine, but when I try > to pass the value to a javascript variable, an error ocurrs (unterminated > string literal). The code snippet below is my attempt. var str = '<%= #{@str} %>'; > The question might be what is firing the bug, is it JS or Ruby? I suspect the Ruby string that is being passed is incorrect. --- Edmond Software Developer | Baobab Health Trust (http://www.baobabhealth.org/) | Malawi Cell: +265 999 465 137 | +265 881 234 717* ** An old dog does not hunt because of speed, but his endurance of the heart.* --90e6ba6e8a229031c6049c51e8f3--