2009/7/4 Learn by Doing <[email protected]>:
>
> Hi Nicholas,
>
> Thanks for your response.  What I meant was that validation should not
> compare the object that is being updated against its own existing copy.
> For example, I am editting an existing object:
>
>   [:aspect => "Aspect-A", :user_id => 5, :third_field => "morning"].
>
> Now, the object is unique in the database according to
>
>   validates_uniqueness_of :aspect, :scope => :user_id
>
> That's all good.  However, when I update the object with the following
> statements:
>
>   self.third_field = "night"
>   save!
>
> Rails returns an error:
>
>   ActiveRecord::RecordInvalid: Validation failed:  Aspect has
> already been taken
>
> Why?  I am just trying to update an existing object, not create a new
> one that would violate the uniqueness validation.

What code are you using for creating and modifying the object before saving it?

Colin

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