我有一个date_select:
<%= f.date_select :date_of_birth, {
:with_css_classes => true,
:order => [:month, :day, :year],
:prompt => true,
start_year: Date.today.year, end_year: Date.today.year - 100}, {:class => "select"} %>
如果出现错误,并且页面重新渲染,则该值将丢失。通过常规选择我设置了参数,但我不知道如何或使用date_select
答案 0 :(得分:0)
参考this
,使用selected
<%= f.date_select :date_of_birth, {
with_css_classes: true,
order: [:month, :day, :year],
selected: @date
prompt: true,
start_year: Date.today.year, end_year: Date.today.year - 100},
{:class => "select"} %>