Nested Attributes Link / Save to An Existing Record

Happy Monday Everyone,
Would you kindly help out a struggling nuby in solving this problem? I
have been researching all over, yet to find a workable solution.

Situation: A model [Announcement] that accepts nested attributes
[Recipients] via many_to_many :through => :awards relationship.

The Desired Outcome:
#1. If a recipient’s email in the announcement form is not found in
the existing recipients’ data, then a new recipient is created.
#2. If a recipient’s email is already in the database, then simply add
award to their existing award profile without creating a new
recipient.id

My Struggle: The desired outcome #1 is satisfied w/ the current
code. However when a recipient’s email is already in the database,
this error shown up “Recipient email already existed” - preventing
saving into their award record. What should I do so that the desired
outcome #2 can be met?

See detailed code here: http://pastie.org/2062009

Many thanks in advance,
Linda

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs