Created
May 21, 2015 12:04
-
-
Save zackperdue/a92bc8efbef8a63a3b51 to your computer and use it in GitHub Desktop.
Overwrite the way the friendly_id gem generates unique slugs.
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
friendly_id :slug_candidates, use: :slugged, slug_column: :namespace | |
def slug_candidates | |
[ | |
[:first_name, :last_name] | |
] | |
end | |
def normalize_friendly_id(value) | |
super.gsub(/\-/, '') | |
end | |
def resolve_friendly_id_conflict(candidates) | |
[candidates.first, User.where(namespace: candidates.first).count].compact.join(friendly_id_config.sequence_separator) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment