Skip to content

Instantly share code, notes, and snippets.

@lxcodes
Created November 14, 2012 15:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lxcodes/4072710 to your computer and use it in GitHub Desktop.
Save lxcodes/4072710 to your computer and use it in GitHub Desktop.
validates :name, presence: true, length: { within: 1..31 }, uniqueness: { scope: :created_by, message: { code: 'non-unique', data: { ->{ find_unique('name') }} } }
def find_unique(name)
..uniqueness magical find...
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment