Skip to content

Instantly share code, notes, and snippets.

@ritikesh
Created June 16, 2020 14:44
Show Gist options
  • Save ritikesh/465b69314bce378a9bedaa17d2ffa8e5 to your computer and use it in GitHub Desktop.
Save ritikesh/465b69314bce378a9bedaa17d2ffa8e5 to your computer and use it in GitHub Desktop.
blog gists
# Before
class User < ActiveRecord::Base
validates_uniqueness_of :username, message: :taken
end
# After
class User < ActiveRecord::Base
handle_record_not_unique(field: ["username"], message: {username: :taken})
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment