Recent Posts by Alexander Ungur
|
Mar 26, 2008
Alexander Ungur
1 post
|
Topic: Advanced Rails Recipes / Multi-model forms 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 |
1 post
