I'm stumbling over a few issues in a current project that are making
me think that I don't know how to use "has 1/belongs to" and
transactions in DataMapper nearly as well as I thought I did. I've
been rewriting/testing this code for days and I still don't understand
what I'm doing wrong, so I thought it might be time to ask for help.

I put together a shortish test script (http://gist.github.com/327132)
that shows my issues. Basically, validation of the mailing address
always fails with ["Type must be one of physical, mailing", "Type must
not be blank"]. Even when I explicitly pass a type, rather than
implicitly letting the relationship handle it.

I assume that how I'm assigning the addresses to the Supplier to
incorrect somehow, but why does only the mailing address fail?

The other issue is that I wanted to make the entire operation as
atomic as possible, if creation of one of the addresses fails then I'd
like to have the entire supplier/key_contact bit rolled back as well.
Hence my attempt at wrapping the Supplier.save method call in a
transaction.

This doesn't seem to have a effect I intended though, as the
transaction is committed even though the address creation fails.

What is the correct way to achieve this kind of atomic create in
DataMapper?

Sorry for such a long message, and thanks for your time :-)

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

Reply via email to