validating_uniqueness_of creating problem while updating


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])
   4. @devtype=Devtype.find_by_id(params[:device][:devtype_id])
   6. if
   8. @device.update_attributes!(params[:device])
   9. redirect_to :action=>"showDevices_admin"
  10. end
  12. end

what is the problem exactly??
Thanx in advance!

Try validates_uniqueness_of :name, :on => :create