Kristis Kristis - 1 month ago 18
Ruby Question

ruby on rails year select issue

my code looks like this

<div class="field form-group">
<%= f.label :date_of_birth %><br />
<%= date_select :date_of_birth, {order: [:month, :day, :year],
prompt: { day: 'Select day', month: 'Select month', year: 'Select year' },
start_year:1950, end_year: Date.today.year}, {required: true}, class: "form-control" %>
</div>


And result is in this photo

What i want that year selection be from 1950 to now.

Thanks for help!

Answer

The following code works perfectly for me:

<%= f.date_select( :date_of_birth, { :order => [:month, :day, :year], :start_year => 1950, :end_year => Date.today.year }, { :required => true, :class => "form-control" }) %>

Note that my date_select control is prepended with f, for the form it belongs to... I think that might be your problem.