Created
August 30, 2019 14:35
-
-
Save eri-b/860f36aa2da13932b0bbf2087b3e9899 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Site < ApplicationRecord | |
| before_save { self.name = name.downcase } | |
| 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 | |
| # when sites are created, they are default public | |
| 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