Ruby on rails: using javascript variable in <%= %> tags in Html.erb
问题 I am trying to use insert an Javascript variable in the <%= %> tags but it prints the variable name verbose. Here is my code <script> function getGraph(agency,device_id) { var i = document.createElement('img'); i.src = '<%= show_graph_hcfcd_url('device_id') %>'; $(graphDiv).appendChild(i); } </script> Now the Problem is URL gets generated just fine except instead of value of device_id, 'device_id' appears in the rest url. Any clues how to get over this? 回答1: <%= %> will interpret the code on