我的index.html.erb中有以下代码
<%= select_tag 'team_id',options_for_select(@teams.map{|team| ["#{team.name} # {team.nick}",team.id] }) %>
我在哪里可以在该块中添加link_to帮助器?我可以为select_tag添加link_to吗?
所需的link_to将转到’/ Teamleader / ID_OF_OPTION_PICKED’
更新:
解决方法
<%= select_tag 'team_id',options_from_collection_for_select(@teams,"id","name") %> <script> $(function(){ $('#team_id').bind('change',function () { var url = "/Teamleader/" + $(this).val() if (url) { window.location.replace(url); } return false; }); }); </script>