![](/img/trans.png)
[英]Ruby on rails: select_tag how to display based on selected value
[英]Ruby On Rails : How to add a link_to in a select_tag
<%= select_tag "profile", options_from_collection_for_select(@profile, 'id','profile_blip'),:onchange => "window.location.replace('/'+this.value);" %>
在'id'
想要放置一些链接是否可能在轨道中
我正在尝试以下代码无法获取,请帮帮我。
<%= select_tag "profile", options_from_collection_for_select(@profile, "profile/publications",'profile_blip'),:onchange => "window.location.replace('/'+this.value);" %>
options_from_collection_for_select创建一个erb代码,如下所示:
<option value="#{profile.id}">#{profile.profile_blip}</option>
在模型类“ Profile”中编写一个返回所需内容的方法。 然后将select_tag更改为此:
<%= select_tag "profile", options_from_collection_for_select(@profile, "new_method_name",'profile_blip'),:onchange => "window.location.replace('/'+this.value);" %>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.