How to: modify date_select to show text field for year
The date select Rails helper is great to get the date/month/year data, however sometime it’s required to customize the default functionality in a way which is sometimes not directly available.
For this particular requirement, it can be achieved by using some default options and adding some more hack to it…
For this, remove the year select from the date select and add a text field with proper naming conventions of a date_select’s select field
Example: “f” is the form reference for user and date_select is implemented for the field “dob”
So, the name of the split date fields comes out to be user[dob(1i)] for year, user[dob(2i)] for month and user[dob(3i)] for year.
Discarding the year from select, we will now manually code the 1i field, like this…
<%= f.date_select :dob, {:discard_year => true} %> <%= text_field_tag "user[dob(1i)]" %>
But, if the user accesses this page again, he might see the year field blank as it’s not yet linked with the object’s dob’s year value. For this we can do it like this…
Depending on what your object is, @user or current_user, we can show pre-filled year as:
<% year = @user.dob.year rescue nil %>
<%= f.date_select :dob, {:discard_year => true} %> <%= text_field_tag "user[dob(1i)]", year %>
Tags: date_select, rubyonrails

Thanks again for posting this so quickly.
It worked very well.
Yes, actually I had an exact requirement a while ago and when I saw you asking for the same thing, I thought it would be better to blog it down so it can be easily accessible for everyone.