This somehow doesn’t seem right. What is the best method to do it?
My method isn’t much better (maybe an expert can clarify us both) but
you can shave off a little work, and enforce a little more structure, by
using the date object instead of the time object:
Depending on what you are doing, there may be an easier way. If you just
want to update a table in your database, then you should use date_select
instead of select_date. The date_select helper will hand the data off to
ActiveRecord in a format that AR can handle for you.
<%= date_select ‘controller’ ‘method’ %>
This will bring the data back parsed out as follows:
… and you can call object.update_attributes params[:object] to have
ActiveRecord do all the work to make it a date and get it into the
database.
If, instead, you need to do something with that value besides putting it
into a model, then the way you or the other respondent are doing it is
pretty much it.
You could dig into ActiveRecord to find the code that translates this,
also.