On Aug 30, 1:11 pm, Kane Baccigalupi <[email protected]> wrote:
> Our team is caught with a problem where we need to resave an object
(without validations) in the after :save hook. It isn't working at
all.

What ex is raised (or bad behavior seen?)

> We have a User model with n Emails. We also have on the user, a
> foreign key that indicates which email object is primary for that
> user. We are using after :save to fill that value to the users first
> email, when an email is provided. Here are the important bits of the
> models:

Not to be the ass that has to deflect the question, just as an aside:
if the email data are what determine whether and which email should be
primary, shouldn't this logic be on a hook on the email object, like
after create?

>
> class User
>   property :id,                   Serial
>   property  :primary_email_id,              Integer
>
>   has n, :emails, :constraint => :destroy
>   belongs_to :primary_email, 'Email', :child_key => :primary_email_id

My experience is that belongs_to that aren't required: false will
silently fail save and save! when they're unset and you imply above
that this is an optional relationship so that might bite you in some
cases (but like a lot of the oddities I've picked up following the
road DM to 1.0, it may no longer apply..)


Good luck,

Yuri

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