在Rails中设置collection_select的默认宽度

时间:2012-03-19 23:24:28

标签: ruby-on-rails

我需要在Rails中为collection_select设置默认宽度。我尝试了这个,但它不起作用:

<%= u.collection_select :program_id, Program.where(:status => true), :id, :name , :include_blank=> true, :class=>'foo'%>

我也尝试过:

<%= u.collection_select :program_id, Program.where(:status => true), :id, :name , :include_blank=> true, {:class=>'foo'}%>

<%= u.collection_select :program_id, Program.where(:status => true), :id, :name , :include_blank=> true, :style=>'width:50%'%>

他们没有工作,任何想法?

1 个答案:

答案 0 :(得分:0)

最后我弄清楚了:

<%= u.collection_select :program_id, Program.where(:status => true), :id, :name , {:include_blank=> true}, {:class=>'foo'}%>

现在有效!