簡體   English   中英

Ruby On Rails:如何在select_tag中添加link_to

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM