On Jan 3, 9:22 am, "Rue the Ghetto" <[email protected]> wrote:
> Hi exploid,
> Thanks for responding with that link, and with haste. It was more
> information than I found on non-advanced relationships, but hasn't really
> answered my questions, particularly the second.
>
> I guess my first question is changing too. The example implies that you can
> add an unsaved object to a many_to_one association, and that it will be
> saved when the parent object is saved. I am using sequel 2.8.0, with
> sequel-model 0.5.0.2, and getting an error stating that the record doesn't
> have a primary key when I try to add an unsaved record. So, any hints about
> what I am doing wrong.

Updating a many_to_one association using association= does not save
the associated or the current record.  Adding an object to a
one_to_many association via add_association saves the associated
record (the current record must already exist in the database, and it
isn't modified).

> Also, adding an unsaved record to a one_to_many association works without
> fail. But when I save the parent record. The records in the association
> don't save with it. They are still new records. Is that expected behavior?

That's because you aren't actually adding a record to the association,
you are just adding it to the cached array.  Sequel doesn't use
proxies for associations.  so instead of association << you use
add_association (e.g. add_comment).

> And of course my question #2 from before stands: when adding a record to a
> many_to_many association, is the join record supposed to be created ...
> because it isn't happening for me.

I'm guessing if you use add_association, it will be.

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
-~----------~----~----~----~------~----~------~--~---

Reply via email to