Datetime_select and Active Record

If I have a form similar to the one below, and ‘start’ is a “string”
field in my Database. Is there a way to take all of the date/time
params and put them into ‘start’ without too much hacking? I would
like this to be as clean as possible.

Start Time
<%= form.datetime_select 'start' %>

To clarify, when “new” is called, my rails app does the standard:
@period =[:whatever])

I’d rather not break that apart if possible. Please let me know if
this doesn’t make


I don’t know if I understand you correctly, but it sounds like you are
concerned that the datetime select is split into multiple selection
lists and you want the date stored as one attribute in the database.

If this is the case, rails should automatically ‘fuse’ all the
parameters into one datetime value as long as your column is set to
datetime and not string.

You got it exactly, however I modified the column attribute to
datetime and simply passing it back, I get an error:

You have a nil object when you didn’t expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.inject

Nevermind, that worked perfectly. Thank you!

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs