Let's go with the example from the docs
class Project < Sequel::Model
many_to_one :portfolio
end
I would like to create a new portfolio, set some things on it from my
project then when I save project, create the portfolio if necessary
and save it.
def some_method_in_project
self.portfolio = Portfolio.new # this blows up :(
portfolio.name = 'something'
self.save # create portfolio if necessary in before_save callback
for me
end
However, due to
def set_associated_object(opts, o)
raise(Error, "associated object #{o.inspect} does not have a
primary key") if o && !o.pk
in model/associations.rb, the portfolio must have already been
created, which seems like a limitation.
Is there any way around this? Or do I have to create the portfolio,
and in a rescue somewhere destroy the timeline if the save or
validation or anything fails?
Thanks,
Will
--
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.