Try user.create just to see what it does. You get a nil in user.id until it gets saved to one. Don't worry about saving anything for now just to test this. I'm having problems too but trying different things out. How is the credit card conversion coming? Did you get this working?
On Sep 11, 4:14 pm, "Daniel Freire" <[EMAIL PROTECTED]> wrote: > 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 -~----------~----~----~----~------~----~------~--~---
