radio_buttom标准用法:
radion_buttom(object,method,option={})
设置<% form_for(@material,:url=>users_material_path) do |f| %>后,f就代表一个对象实例,在页面中使用radio_buttom有一点小小的变化
<% {"0"=>"男","1"=>"女"}.each do |key,value| %>
<%= f.radio_button(:sex,key.to_s) %><%= value.to_s %>
<% end %>
<%= f.radio_button(:sex,key.to_s) %><%= value.to_s %>
<% end %>
就是不在需要第一个参数了,如下所示,使用标准用法将会报错,为了这个问题小小的郁闷的一把,记录下
1 <% {"0"=>"男","1"=>"女"}.each do |key,value| %>
2 <%= f.radio_button(:material,:sex,key.to_s) %><%= value.to_s %>
3 <% end %>
2 <%= f.radio_button(:material,:sex,key.to_s) %><%= value.to_s %>
3 <% end %>