I'm trying out Ryan Bates' multi-object form technique shown in one of
his Rails-casts (railscasts.com/episodes/75). If you use a fields_for
similar to that shown (here: Parked at Loopia), you get a
Server Error 500:
The problem appears to be that Rails doesn't know to put the date-
select information into an Array.
That certainly looks like it. Have a look at trac and see if anyone
else has reported this, otherwise you'll need to open a new ticket
yourself. Do you feel like taking a crack at fixing it too
For future Googlers, until I can get a good work around what I'm doing
is using the snazzy Chronic gem. This means I can use a simple text
field and parse the _before_type_cast version into a Date (or Time)
object.
I meant my theory looks to be incorrect: that the date_select params
were the source of the trouble.
By using the Chronic gem I thought I could get rid of the date_select
field and then all would be well, but that didn't work. It appears
that it's the combination of using select fields and text fields that
causes the trouble.
I'm not really sure how to solve the problem at the moment. I'm
poking around in the AbstractRequest.parse_request_parameters code,
but I can't even get simple requests to work in IRB, so it's taking me
a little longer than I'd like it to be.
Okay, Googlers. I have this figured out. I don't have a good
solution, but I have a work-around until I can write a patch.
You'll notice in Ryan Bate's method that he has you use an ":index =>
nil" option on text_fields for your fields_for. This option is _not_
recognized by the select helper. Until I can write a patch, you need
to use the select_tag helper as follows:
I haven’t yet. I’ve got a little busy as of late. Here’s the thing: this is already supported, it just isn’t revealed.
What I’d suggest doing in the mean time (I will write the patch this weekend for you), is using a text field and leveraging the Chronic gem to convert plain-English time phrases into Date or Time objects.
In summation, this feature is already supported, it's just not as
expected. I'll be submitting a patch with documentation enhancements
and a new test to show an example of this usage.