Validating_uniqueness_of creating problem while updating

Hi!

Im validating name field in “dev” model by checking its uniqueness. but
while editing that particular entry, the system again validates for
uniqueness of name. so if i dnt change name while editing , it gives me
error: name has already been taken.

my update code is :

  1. def updateDevice
  2.   @device=Dev.find(params[:id])
    
  3.   @devtype=Devtype.find_by_id(params[:device][:devtype_id])
    
  4.   if request.post?
    
  5.       @device.update_attributes!(params[:device])
    
  6.       redirect_to :action=>"showDevices_admin"
    
  7.     end
    
  8. end
    

what is the problem exactly??
Thanx in advance!
sups

View this message in context:
http://www.nabble.com/validating_uniqueness_of-creating-problem-while-updating-tp18231473p18231473.html
Sent from the RubyOnRails Users mailing list archive at Nabble.com.

Try validates_uniqueness_of :name, :on => :create