Kristis Kristis - 1 year ago 107
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:}, {required: true}, class: "form-control" %>

And result is in this photo

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

Thanks for help!

Answer Source

The following code works perfectly for me:

<%= f.date_select( :date_of_birth, { :order => [:month, :day, :year], :start_year => 1950, :end_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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download