Skip to content

Instantly share code, notes, and snippets.

@eri-b
Last active September 14, 2019 16:46
Show Gist options
  • Select an option

  • Save eri-b/aa879ef430a4b88dc433e7ef33906ca6 to your computer and use it in GitHub Desktop.

Select an option

Save eri-b/aa879ef430a4b88dc433e7ef33906ca6 to your computer and use it in GitHub Desktop.
class Site < ApplicationRecord
before_create :lock_init
VALID_NAME_REGEX = /\A[a-zA-Z\d\-]+\z/i # letters, numbers, dashes
validates :name, presence: true, uniqueness: true, length: { maximum: 50 }, format: { with: VALID_NAME_REGEX }
has_secure_password validations: false
private
def lock_init
self.locked = false
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment