I am currently working on ruby on rails 3 tutorial by michael hartl. I am running into this problem when I try to call db:migrate. Could someone help me figure out why its a
Nothing wrong with your migration. The error simply means you have existing email duplicates data in db.
Check your users table, set unique emails for existing rows or delete these rows. Then run the migration again.
Update: Please note that even if you remove the unique constraint from migration and add validates_uniqueness_of :email
to your Active Model, the problem would still eat you in the future.
The root problem is your data is in a 'bad' state. If you have two rows having the same email address (or it's also possible they both have blank email), after adding validates_uniqueness_of :email
your User
model instance for these two rows won't be valid. So it's still a data problem you have to fix.