validation - Rails Validates_uniqueness of scope not working -


My beliefs have increased the "already taken email" error on the method of creating.

I have this belief in my customer model:

  valid: email, uniqueness = & gt; {: Area = & gt; : Account_id ,: case_sensitive = & gt; False}   

And it is that I am looking into my logs:

  Customer load (0.4ms) selection 'customer' * `WHERE 'customer` .` ​​account_id` = 2 and `customer` from customers. Mail '=' xxxxx@gmail.com 'LIMIT 1 (0.1 mms) Select customer client (0.8 mms)' one from customers 'where` customer `.mail' = binary 'xxxxx@gmail.com' LIMIT 1 customer Select Axiom (0.3ms) 1 as' Customer 'from one (`Customer'. 'Mail' = 'xxxxx@gmail.com' and` `` _account_id` of customers `2) LIMIT 1 (0.2 ms) rollback < / Code>  

Thanks for the help.

Your scope is reducing e-mail search in a given account_id (= 2). Not sure that this is your intention behavior, but if you want to find it also as another account ID, then you should remove the scope.

Validation is failing because the email you entered has already been taken, in this way, they are doing the same thing that you have asked them to do ...

Comments