0
select_tag通常form_for
如何在form_form
我做p.text_field :my_colum_name
但如果我有一個選擇的標籤?
我嘗試以下,但沒有奏效
<%=p.select_tag :conditions,options_for_select([ "a", "b", "c" ], "a") %>
它說select_tag是一個未定義的方法
select_tag通常form_for
如何在form_form
我做p.text_field :my_colum_name
但如果我有一個選擇的標籤?
我嘗試以下,但沒有奏效
<%=p.select_tag :conditions,options_for_select([ "a", "b", "c" ], "a") %>
它說select_tag是一個未定義的方法
你想要的是這樣的:
<%= p.select :conditions, [ "a", "b", "c" ] %>
兩個變化:(1)select
是方法名使用FormBuilder時,和(2)它需要的數組選項,沒有options_for_select
(它知道存儲在FormBuilder中的對象的當前值)。
沒關係。
<%=p.select_tag :conditions,options_for_select([ "a", "b", "c" ], "a") %>
工作