Reputation: 13308
Just trying to show grouped radio buttons on a page and get a selected value on post request.
%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
I debugged
pp params
{"authenticity_token"=>"DwDYHY/mm1WEMBXZuHAN+4fqksojTHZVwuTob8LxDvA=",
"action"=>"delivery_type_create",
"controller"=>"orders"}
I tried this
%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
but it does not show itself at all, only h2 and the another part of a page are shown.
What did I do wrong?
Upvotes: 0
Views: 417