尝试将类添加到选择标记
<%= f.select(:ptype, options_for_select(TourParticipation::PTYPES, selected: "traveler", disabled: "Role:") , { :class => "widens" } ) %>
结果
<select name="tour_participation[ptype]" id="tour_participation_ptype"></select>
为什么班级没有应用于我的选择标签?
答案 0 :(得分:0)
您忘记了html_options
之前options
哈希。试试这个:
<%= f.select(:ptype, options_for_select(TourParticipation::PTYPES, selected: "traveler", disabled: "Role:") , {}, { :class => "widens" } ) %>
参见定义: http://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#method-i-select