TOn Wednesday, October 3, 2012 4:45:54 PM UTC-7, Paul Elliott wrote: > I am trying to build a tree of objects that won't be persisted until a later > date. I can't use the `add_*` methods because they require the parent object > to be persisted prior to calling them. Is there a way in sequel to link a > bunch of unpersisted objects together and persist the whole graph at some > later time? For example: > > > ``` > class Author > one_to_many :books > end > > > class Book > many_to_one :author > end > > > author = Author.new # build an author > author.books << Book.new # add a new unsaved book > author.books << Book.new # add a new unsaved book > author.save # save the author and the books > ```
This is basically what the nested_attributes plugin does, using the instance_hooks plugin under the covers. Jeremy -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/sequel-talk/-/V7Bqs6YDNoMJ. 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.
