Ruby on rails rails日期\u选择类将不生效

Ruby on rails rails日期\u选择类将不生效,ruby-on-rails,Ruby On Rails,我有以下日期选择用法 <%= f.date_select :birthday, :order => [:month, :day], :prompt => { :day => 'Select day', :month => 'Select month' }, :html => {:class => "select birthday"} %> 但是该类不会显示在html中 <select id="profile_birthday_2i" nam

我有以下日期选择用法

<%= f.date_select :birthday, :order => [:month, :day], :prompt => { :day => 'Select day', :month => 'Select month' }, :html => {:class => "select birthday"} %>
但是该类不会显示在html中

<select id="profile_birthday_2i" name="profile[birthday(2i)]">
<select id="profile_birthday_3i" name="profile[birthday(3i)]">
我也试过

<%= f.date_select :birthday, :order => [:month, :day], :prompt => { :day => 'Select day', :month => 'Select month' }, :class => "select birthday" %>

这也不管用。有什么想法吗?

HTML选项是日期选择方法的第四个参数,而不是第三个参数中的键

从:

所以你想要:

f.date_select :birthday, { :order => [:month, :day], :prompt => { :day => 'Select day', :month => 'Select month' } }, {:class => "select birthday"} 
您需要使用html_选项,而不是html来指定类

我相信这会起作用,尽管我还没有测试过

<%= f.date_select :birthday, :order => [:month, :day], :prompt => { :day => 'Select day', :month => 'Select month' }, :html_options => {:class => "select birthday"} %>
请参见此处的API说明:

注:文件说明:

如果在html_选项散列中传递了任何内容,它将应用于集合中的每个select标记


因此,请确保您希望该类在每个元素上都出现。

谢谢Kevin,这对我来说不起作用。见道格拉斯的建议。
<%= f.date_select :birthday, :order => [:month, :day], :prompt => { :day => 'Select day', :month => 'Select month' }, :html_options => {:class => "select birthday"} %>