class State < ActiveRecord::Base validates :name, uniqueness: {scope: :abbreviation} scope :for_abbreviation, ->(abbrev){where(abbreviation: abbrev)} scope :for_name, ->(name){where(name: name)} end