On Oct 23, 12:22 am, Clive Crous <[email protected]> wrote: > 2009/10/23 Jeremy Evans <[email protected]>: > > > I actually work around this Sequel behavior in the application I'm > > currently working on, and it got me thinking about whether Sequel's > > current behavior is best. > > I'm sorry about the 2nd post but it's really bugging me. I cannot > figure out how it would ever happen in code where I have the > combination of events you describe. Why would you ever try request > albums for an artist that's new and not yet saved? I've created many > many sites and applications now using Sequel and I can't see how this > scenario would ever even happen. Surely at the time of creation you're > aware that you're creating a new object so you don't attempt to read > from it while it's still being set up prior to the first save.
If you know you have a new object, I think the current behavior makes more sense. However, if you have code that's designed to work with any model object (new or saved), Sequel's current behavior requires you to check whether the model object is new first. Also, if you know you have a new object, you probably wouldn't attempt to add any associated objects (that will still fail with an error if you do). sferik's code is a generic association displayer for a form that can handle both new and saved model objects. The application that I'm working on only needs to deal with saved objects in production, but the project manager wanted an example form that had to work with a new model object. Jeremy --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sequel-talk" 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/sequel-talk?hl=en -~----------~----~----~----~------~----~------~--~---
