Hi everyone,
I had a doubt when I was doing homework.
When I run this through Rails Console:
>> user = User.new(:name => "Daniel", :hobby => "swimming", :age => 23,
:email_addr => "[EMAIL PROTECTED]", :credit_card => "1234 1234 1234
1234")
=> #<User id: nil, name: "Daniel", hobby: "swimming", age: 23, created_at:
nil, updated_at: nil, email_addr: "[EMAIL PROTECTED]", credit_card:
"1234 1234 1234 1234">
>> user.save
=> true
>> user = User.new(:name => "Bob", :hobby => "swimming", :age => 23,
:email_addr => "[EMAIL PROTECTED]", :credit_card => "1234 1234 1234 1234")
=> #<User id: nil, name: "Bob", hobby: "swimming", age: 23, created_at: nil,
updated_at: nil, email_addr: "[EMAIL PROTECTED]", credit_card: "1234 1234 1234
1234">
>> user.save
=> true
>> user = User.new(:name => "Jane", :hobby => "swimming", :age => 23,
:email_addr => "[EMAIL PROTECTED]", :credit_card => "1234123412341234")
=> #<User id: nil, name: "Jane", hobby: "swimming", age: 23, created_at:
nil, updated_at: nil, email_addr: "[EMAIL PROTECTED]", credit_card:
"1234123412341234">
>> user.save
=> false

Observe that when I create a User with the credit_card = "1234 1234 1234
1234" (format #2), the validates_uniqueness_of doesn't work. The samething
happens when I use format #1, but with format #3 it works!
I think that before_save and before_create callbacks are running after the
validates_uniqueness_of :credit_card.

Can someone help me?


-- 
---------------------------------------------------------------------------
Daniel Almeida Freire

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "ruby-on-rails-programming-with-passion" group.
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/ruby-on-rails-programming-with-passion?hl=en?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to