我正在尝试将类应用于使用Ruby构建的select表单元素。
这是f.select:
<%= f.select :within, ["5km", "50km", "100km", "250km", "500km", "1000km"], { :include_blank => 'Anywhere', :selected => (params[:listing][:within] unless params[:listing].nil? || !params[:listing].has_key?(:within)) } %>
上课去哪儿了?我的班级是:
:class => 'input-medium'
谢谢!
答案 0 :(得分:2)
请参阅 the documentation ,特别是html_options
参数。
在您的问题的结尾添加另一个参数:
{ class: "input-medium" }
总而言之
<%= f.select :within, ["5km", "50km", "100km", "250km", "500km", "1000km"], { :include_blank => 'Anywhere', :selected => (params[:listing][:within] unless params[:listing].nil? || !params[:listing].has_key?(:within)) }, { class: "input-medium" } %>