Skip to content

Instantly share code, notes, and snippets.

@zackperdue
Created May 21, 2015 12:04
Show Gist options
  • Save zackperdue/a92bc8efbef8a63a3b51 to your computer and use it in GitHub Desktop.
Save zackperdue/a92bc8efbef8a63a3b51 to your computer and use it in GitHub Desktop.
Overwrite the way the friendly_id gem generates unique slugs.
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