<%- [['Agree Strongly', 7],
['Agree Mostly', 6],
['Agree Somewhat', 5],
['Neither Agree Nor Disagree', 4],
['Disagree Somewhat', 3],
['Disagree Mostly', 2],
['Disagree Strongly', 1]].each do |button| %>
<%= radio_button_tag :name, button.first, :value => button.last %>
<% end %>
甚至更好地列出控制器
...控制器
def some_action
@choices = [['Agree Strongly', 7],
['Agree Mostly', 6],
['Agree Somewhat', 5],
['Neither Agree Nor Disagree', 4],
['Disagree Somewhat', 3],
['Disagree Mostly', 2],
['Disagree Strongly', 1]]
end
...意见
<% @choices.each do |button| %>
<%= radio_button_tag :name, button.first, :value => button.last %>
<% end %>