# Problems with validates\_uniqueness\_of

**URL:** <https://www.ruby-forum.com/t/problems-with-validates-uniqueness-of/176581>\
**Category:** Rails\
**Created:** [October 2, 2009, 5:38pm UTC](https://www.ruby-forum.com/t/problems-with-validates-uniqueness-of/176581 "2009-10-02T17:38:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![arosasj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/919ad9/32.png) [@arosasj](https://www.ruby-forum.com/u/arosasj)\
**Post date:** [October 2, 2009, 5:38pm UTC](https://www.ruby-forum.com/t/problems-with-validates-uniqueness-of/176581/1 "2009-10-02T17:38:13Z")

</div>

Hi to everybody, well i recently became a RoR developer, web i was  
following the video class from Lynda, and i introduce more code in my  
aplicacion, my application is a music store web site, ok so i add the  
funcionality of add clients, for that i need from my client, his user  
and password, so it will be 1 user per client, for that reason i use at  
my model

validates\_uniqueness\_of :user

############## here is my model ###########3  
class Customer \< ActiveRecord::Base

```
has_many :orders

```

attr\_accessible :first\_name,:last\_name,  
:zip\_code,:user,:hashed\_password

validates\_uniqueness\_of :user

##########################################

and when i run the application  
and want to add a diferent user from those are exist it work fine,  
bue when i want to add a user that is already add db it blow up  
and apears this :  
/////////////////////7777  
ArgumentError in CustomersController#create

```
 too few arguments

```

app/controllers/customers\_controller.rb:71:in `format' app/controllers/customers_controller.rb:71:in`create’  
////////////////////////77

ok so, what i found there was  
70\> flash[:notice] = ‘Error!!! intentelo de nuevo’  
71\> format.html { render :action =\> “new” }  
72\> format.xml { render :xml =\> @customer.errors, :status =\>  
:unprocessable\_entity }

################  
i change those , the first line for  
70\> flash[:notice] = ‘Error!!! intentelo de nuevo’  
71\> redirect\_to (:action =\> ‘new’ )

### with this change i fix the problem, but, nothing appear i mean the

message from the validates\_uniqueness\_of , it should appear that the  
user is already in use or something similar.

Anyone can help me ?!?!!
