Unique field

Anyone point me in the direction of a tutorial to explain how I can
add a checker to a form field to see whether it is already used within
the database, i.e. check whether the username entered is unique

validates_uniqueness_of

http://api.rubyonrails.com/classes/ActiveRecord/Validations/ClassMethods.html#M001896