26 Mar 2008, 09:38
Generic-user-small

Alexandru Ungur (1 post)

First of all, thank you for a great book. I found it very useful.

On the multi-models forms recipe, there’s one little gotcha: all goes well and smooth until you get to the save part. There, things may go smooth if all your data in child rows is valid. Or you can even get nice validation errors if you use validates_associated. However if the save of child rows fails for whatever reasons (say, because of using callbacks, that properly return false hoping to break the save chain) you run out of luck. No child rows being saved and no errors whatsoever so that you can have a clue what’s going on. In other words, to quote from AWDwR:

“Finally, there’s a danger here. If the child row cannot be saved (for example, because it fails validation), Active Record will not complain - you’ll get no indication that the row was not added to the database.”

Perhaps it would be a good idea to remind the users of this recipe of that danger, might spare them of a few headaches :-)

Have a great day

11 Jun 2008, 20:24
Generic-user-small

Kurt Wiedenhoeft (1 post)

I am also enjoying this book. I have had good luck with this recipe, but I’m running into a problem when I try to add a date or date/time select box to the “tasks” section. I have the code working great, but as soon as I add this to my partial, it breaks:

<%= task_form.date_select :pickup_at %>

When I add a new task and submit the form, I get a 500 error, and the following message in the log:

“Conflicting types for parameter containers. Expected an instance of Array but found an instance of Hash. This can be caused by colliding Array and Hash parameters like qs[]=value&qs[key]=value.”

If I manually add the related record to the table, it will render the date select properly and I can submit changes without error. However, any new tasks I add will cause the submit to fail. This looks very much like the problem mentioned here:

http://dev.rubyonrails.org/ticket/10551

I applied the patch supplied, but it didn’t make a difference. Has anyone else run into this, and maybe found a solution?

Thanks,

Kurt

09 Oct 2008, 03:32
Generic-user-small

stefan Penner (1 post)

Hey Kurt, I also encountered this issue. I realize this post is quite old but here is my solution to the datetime_select issue:

http://53cr.com/blog/2008/09/resolved-datetime_select-virtual-attribute-issue-rails-21/

Hopefully this can help some people

stef

29 Oct 2008, 13:20
Generic-user-small

Hiro SHINOHARA (1 post)

Stef

Thanks so much. The article you posted here was completely helpful!

– Hiro

14 Mar 2009, 10:09
Generic-user-small

Hemant Khemani (1 post)

Hi,

As already mentioned by Kurt date_select and time_select has issues with multi-model form when a new record is being saved.You can find the cause of the problem and the workaround in this blog post http://agilerails.wordpress.com/2009/03/11/date_select-time_select-doesnt-work-with-auto_prefix-object/

Thanks

  You must be logged in to comment