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

Ruby On Rails : How to add a link_to in a select_tag

本文关键字:tag 添加 to link select Rails On Ruby      更新时间:2023-09-26
 <%= 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);" %>