One thing that might serve as an indicator is if new_record? is true for the returned instance.
On Dec 12, 6:02 pm, phatmann <[email protected]> wrote: > I know this topic has been discussed before, but it was buried amongst > a long thread about exceptions, so I wanted to raise it anew. > > The current situation is that the Model#create method "silently" fails > if the validations fail. That is, there is no exception, and the > return value is basically the same for success or failure; i.e. the > model instance. What this means is that code that uses the return > value is fooled into thinking the create() succeeded even though it > failed. This leads to hard to find bugs. I know this from experience :- > ( > > The return value from the create can be checked to determine success > or failure, but this is a pain and easy to forget to do. > > So my suggestion is this: create() should return nil on failure. This > solves all the aforementioned problems, and seems like the obvious > solution. Am I missing something? > > I could not find a ticket filed for this. If I missed it, let me know. > Otherwise I will file one, possibly with the patch. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "DataMapper" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/datamapper?hl=en -~----------~----~----~----~------~----~------~--~---
