so in my show.html.erb file for onf the controllers i have had
<% content_for :head do %>
<script type="text/javascript">
var filepath= "/flexpaper/" + <%= @exam.filename.to_s %> + ".swf"
var flashvars = {
SwfFile : escape(filepath), ....
now this seemed to be the workaround solution I used but when I tried to achieve the same result the other way around as follows
<% content_for :head do %>
<script type="text/javascript">
var filepath= <%= "/flexpaper/" + @exam.filename + ".swf".to_s %>
var flashvars = {
SwfFile : escape(filepath), ....
i.e to generate filepath in ruby rather than javascript I get undefined error for filepath. now i understand that is because of escape as it didn't get filepath as a string i.r "stuff.." rather something like stuff.. so the escape errors out. but I don't see why? any ideas?
P.s- also any suggestions for UJS style organisation. I have every other js residing somewhere in other file and included in header as needed except for this somewhat dynamic one. I can't have ruby code in included js files and didn't wanted to have a javascript controller as like ryan bates railscast to generate this minor script. So any other simple solution.