我如何在options_for_select中使用javaScript变量同时调整Ruby on Rails

时间:2015-03-04 17:15:34

标签: javascript jquery ruby-on-rails ruby

我从 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| [... ... ^

谢谢!

0 个答案:

没有答案