Handling Date Fields (date_select tutorial?)

Summary: is there a “how-to” somewhere that show how to use

I have been going round and round trying to figure out how to capture
and edit dates using ROR’s built-in functionality. If I am just
binding a database date field to the model object and use the standard
view (ie. not using date_select), that works fine. But as soon as I
replace (override) the new or edit view and have to create the date
capture/edit functionality myself, I am lost.

From googling the past few hours, I understand I should (could) use the
date_select widget. But I can only find info of people talking about
it rather than “this is what you put in your html (for initial capture
and edit), and this is what your controller or model object needs to
handle that data”.

I have been using trial and error to get a simple date_select to work,
but am getting no where. Does anyone know of a simple how-to on the
internet, because I am not finding it.


I answered my own question. I was trying to make it more complicated
than it needed to be.

For others that try this after me, all you need to do is…instead of
putting into your html the usual <input …> form element, simply

<%= date_select ‘your_model_name’, ‘your_date_field_name’, {:order =>
[:month, :day, :year]} %>

Do this in your “new” as well as “edit” views, and everything else is
taken care of.