How to have default date for date_select

lo there all,
i want to have a date_select heper default to the year 2006, but cant
seem to find out how to pull it off.
any takers ?

I think the fields just show the current value of the object.
Have you tried something like this?

<%= model.date = Date.today; date_select :model, :date %>

date_select will show the current value of the object.
you can set a default value of this object in controller.
@object.date= ‘2006-01-01’

is it possible to have not a date by default but day in the days field,
month in the months field and year in the years field?
does select_date have an option to do this?

jil wrote:

is it possible to have not a date by default but day in the days field,
month in the months field and year in the years field?
does select_date have an option to do this?

up

On Jan 11, 10:28 pm, Shawn B. [email protected]
wrote:

i want to have a date_select heper default to the year 2006, but cant
seem to find out how to pull it off.

Assign the default value you want, in the new action. date_select()
will do the right thing with it in the view.

e.g.

def new
@calendar_event = CalendarEvent.new :start_date =>
“2006-01-01”.to_date
end

Are you sure you want the default year to be 2006, and not the current
year?

e.g.

def new
@calendar_event = CalendarEvent.new :start_date =>
Time.parse(“#{Time.today.year}-01-01”)
end

Ciao,
Sheldon.