Here??™s what really happens in a situation like that: if a user has provided
an invalid date (like June 31, 2007), the helper method attempts to use the values to create a date
object (from within ActiveRecord). The Ruby Date.new method throws an error, and that bubbles
up to the Active Record error level, eventually raising an AttributeAssignmentError.
The fix for these type of errors is generally not ActiveRecord-code-based, but rather something
that should be dealt with in your business logic (controller code) or at a specific data-value
level (i.e., scrub the data within your database).
CHAPTER 6 ?– ACTIVE RECORD TESTING AND DEBUGGING 152
MultiparameterAssignmentErrors
This error is raised in the same way as the AttributeAssignmentError and is really just a collection
of those errors.
Preparing for Problems
Handling exceptions is really about preparing for potential problems. We??™ve now covered the
details of the 17 basic error classes that Active Record defines. We??™ve shown examples of how
and why each type of error is raised, and hopefully, we??™ve given you enough information to
help you avoid most of them in your applications.
Pages:
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349