I believe that datetime_select
is black magic. What I'm really trying to figure out is the whole 1i
,2i
,3i
,4i
... multiple parameters stuff. Specifically how is it handled in the back end (activerecord, something else?). What's with the 'i' after the order-number? Is it a type-specifier? If so what are other types that are available? I've read the source of date_helper.rb and it's quite opaque.
Here's my motivation:
I've got a :datetime
column in my model and I want to input in the view via two text_field
s: one for date and one for time. They need to be validated, merged together, then stored into the datetime column. Ultimately I'll be using a javascript calendar to input dates into the date field.
So has anybody done this? I tried using virtual attributes (incredibly undocumented besides the rudimentary railscast) and the issue was that when a new activerecord object is created and has nil attributes, the virtual attribute fails (undefined method strftime
for nil class, which makes sense).
Anybody have any suggestions or best practices? Thanks!