Sha256: 6b9d4b986ca78e76c2b3a2d6c4f248c95c3cf025a4a54cf03141f711be4ab38b
Contents?: true
Size: 864 Bytes
Versions: 1
Compression:
Stored size: 864 Bytes
Contents
require "friendly_id" require "friendly_id/mobility/version" module FriendlyId module Mobility class << self def setup(model_class) model_class.friendly_id_config.use :slugged end def included(model_class) advise_against_untranslated_model(model_class) mod = Module.new do def friendly super.i18n end end model_class.send :extend, mod end def advise_against_untranslated_model(model) field = model.friendly_id_config.query_field if !model.respond_to?(:translated_attribute_names) || model.translated_attribute_names.exclude?(field) raise "[FriendlyId] You need to translate the '#{field}' field with " \ "Mobility (add 'translates :#{field}' in your model '#{model.name}')" end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
friendly_id-mobility-0.1.0 | lib/friendly_id/mobility.rb |