使用SimpleForm为每个选择选项添加一个类

我想使用SimpleForm从数组(而不是模型集合)构建一个select输入,并为每个option设置不同的类。

我希望这会起作用:

 f.input :method, collection: [ ["option text", "option_value_1", { class: "class_name_1" }], ["option text 2", "option_value_2", { class: "class_name_2" }] ] 

问题是它会产生:

  option text option text 2  

我怎样才能以简单的forms做我想要的(价值应该是“期权价值”)?

这在使用集合时似乎是一个限制,请参阅SimpleForm 在此处解释的作者。 他建议使用以下forms的解决方法:

 f.input :method, :as => :select do f.select :method, [['option text', 'option_value_1', {"class" => "class_name_1"}], ['option text 2', 'option_value_2', {"class" => "class_name_2"}]] end