Generate Rails Model With Unique Attribute
When generating a rails column, you can specify an attribute to have a unique constraint like this:
rails g model Song title:string:uniq
In your migration, this will look like:
add_index :songs, :title, unique: true
Tweet