0
只是試圖在頁面上顯示分組單選按鈕,並在發佈請求時獲取選定值。Ruby on Rails中的單選按鈕列表3.2
%h2 Choose your delivery type
-DeliveryType.all.each do |dt|
%p
=radio_button_tag "delivery_type", dt.name, false
=label_tag "delivery_type_#{dt.id}", dt.name
%p= button_to "Forward", delivery_type_create_path
def delivery_type_create
#params[:delivery_type] is nil
end
我調試
pp params
{"authenticity_token"=>"DwDYHY/mm1WEMBXZuHAN+4fqksojTHZVwuTob8LxDvA=",
"action"=>"delivery_type_create",
"controller"=>"orders"}
我想這
%h2 Choose your delivery type
-form_tag do
-DeliveryType.all.each do |dt|
%p
=radio_button_tag "delivery_type", dt.name, false
=label_tag "delivery_type_#{dt.id}", dt.name
%p= button_to "Forward", delivery_type_create_path
,但它並沒有顯示自己可言,只有H2和頁面的另一部分所示。
我做錯了什麼?