You could use find_or_create_by_note, too

2009/10/7, Marnen Laibow-Koser <[email protected]>:
>
> Greg Donald wrote:
>> On Wed, Oct 7, 2009 at 8:15 AM, RVince <[email protected]> wrote:
>>> � � � �cnote.channel_id = @channel.id
>>> � � � �cnote.associate_id = current_associate.id
>>> � � � �g=cnote.save
>>
>> begin
>>   cnote.save!
>> rescue
>>   flash[:notice] = 'channel note failed to save'
>> end
>>
>> or you could check to see if it exists before trying to save it.
>>
>> cn = Channelnote.find_by_note( params[:channelnotes] )
>> cnote.save unless cn
>
> Or put a validates_uniqueness_of in the app.
>
>>
>>
>> --
>> Greg Donald
>> http://destiney.com/
>
>
> Best,
> --
> Marnen Laibow-Koser
> http://www.marnen.org
> [email protected]
> --
> Posted via http://www.ruby-forum.com/.
>
> >
>

-- 
Von meinen Mobilgerät aus gesendet

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: 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/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to