我从 id 或 div 返回变量的javaScript代码:
<script type="text/javascript" >
function passParameters(modalvalues) { var node_name =
modalvalues.getAttribute("node_name");
$(".node-name").text(node_name); $("#node_name").val(node_name); }
</script>
我的Ruby代码:
<%= select_tag :relaunch, options_for_select(@restarts.where("node_name like
**javascriptnodeVariable**).collect {|u| [ "#{u.schedule_name}-#{u.node_name}", u.node_name ] }) %>
我正在尝试:
<%= select_tag :relaunch, options_for_select(@restarts.where("node_name like #{:id=>'node_name'}").collect {|u| [ "#{u.schedule_name}-#{u.node_name}", u.node_name ] }) %>
但是我收到了这个错误:
C:/Sites/SIB/app/views/welcome/index.html.erb:495: syntax error, unexpected tASSOC, expecting '}' ...s.where("node_name like #{:id=>'node_name'}").collect {|u| [... ... ^
谢谢!