![](/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.