我正在尝试使用form_for select helper,我在尝试选择数字时遇到错误。这是我的路线:
<%= f.select(:reminder, options_for_select([ ['0','0'], ['10','10'], ['25','25'] ], {}, {:class => 'form-control'} )) %>
我收到此错误:
wrong number of arguments (3 for 1..2)
我尝试过多种不同的方法来格式化我的语法,但我陷入了僵局。感谢任何知道我的错误选择助手的语法的人。顺便说一下,我使用这个页面作为参考:
http://guides.rubyonrails.org/form_helpers.html#making-select-boxes-with-ease http://apidock.com/rails/ActionView/Helpers/FormOptionsHelper/options_for_select
答案 0 :(得分:1)
您对options_for_select的结束圆括号位于错误的位置。尝试:
<%= f.select(:reminder, options_for_select([ ['0','0'], ['10','10'], ['25','25'] ]), {}, {:class => 'form-control'} ) %>
options_for_select需要1或2个参数(第二个参数是可选的)。由于错位的右括号,你传递3个参数。