这是我的代码:
<%= f.select :area,options_for_select([['a','a'],['b','b'],['c','c']]),{},{:class => 'span3 controls controls-row'},:selected => params[:area] %>
结果是:
ArgumentError in Users#edit Showing /home/airson/rails_projects/friends_of_local/app/views/users/edit.html.erb where line #17 raised: wrong number of arguments (5 for 4)
为什么…..@@?
解决方法
不需要使用:选择只是将你的params [:area]单独传递给options_for_select作为第二个参数:
<%= f.select :area,'c']],params[:area]),{ :class => 'span3 controls controls-row' } %>
将选择您的参数[:area]的最后一个值.
希望有帮助)