Module: Mongoid::Translate::Slug

Extended by:
ActiveSupport::Concern
Defined in:
lib/mongoid/translate/slug.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#to_slugString

Return slug. Didn’t want to mess with to_param.

Examples:

document.to_slug

Returns:

  • (String)


24
25
26
27
# File 'lib/mongoid/translate/slug.rb', line 24

def to_slug
  locale = languages.include?(I18n.locale) ? I18n.locale : main_language
  translations.where(language: locale).one.slug
end