Skip to content

Instantly share code, notes, and snippets.

@leomayleomay
Created April 21, 2010 13:23
Show Gist options
  • Save leomayleomay/373801 to your computer and use it in GitHub Desktop.
Save leomayleomay/373801 to your computer and use it in GitHub Desktop.
Say I have a Person model,
app/models/person.rb
class Person < ActiveRecord::Base
validates_uniquess_of :name
end
db/migrate/2010009912_add_index_to_people.rb
add_index :people, :name, :unique => true
How could I enforce the unique index in the ActiveRecord?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment