-
-
Save marr/4114ae6eb1804ea0737c35612a1bfeab to your computer and use it in GitHub Desktop.
This file contains 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 Slug < ActiveRecord::Base | |
before_validation :generate_slug | |
validates :slug, presence: true, uniqueness: true | |
private | |
def generate_slug | |
self.slug = self.value.parameterize | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment