Mass assignment (doing User.new(params['user'])
) isn't very good practice. Anyway, you need to obtain a DateTime
or Time
object somehow. You can name the fields how you want, for example:
<select name="user[date_of_birth][year]" id="user-date_of_birth-year>
<option value="1980">1980</option>
<!-- other options -->
</select>
<select name="user[date_of_birth][month]" id="user-date_of_birth-month>
<option value="1">January</option>
<!-- other options -->
</select>
<select name="user[date_of_birth][day]" id="user-date_of_birth-day>
<option value="1">1</option>
<!-- other options -->
</select>
and in your controller:
dob = DateTime.new(
params['user'][date_of_birth][year].to_i,
params['user'][date_of_birth][month].to_i,
params['user'][date_of_birth][day].to_i
)
User.new(:name => params['user']['name'], :date_of_birth => dob, ...)