Module: FriendlyId::Reserved::Configuration

Defined in:
lib/friendly_id/reserved.rb

Overview

This module adds the :reserved_words configuration option to FriendlyId::Configuration.

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Instance Attribute Details

- (Object) reserved_words

An array of words forbidden as slugs.



63
64
65
# File 'lib/friendly_id/reserved.rb', line 63

def reserved_words
  @reserved_words ||= @defaults[:reserved_words]
end

Instance Method Details

- (Object) base=(base)

Overrides Configuration#base to add a validation to the model class.



56
57
58
59
60
# File 'lib/friendly_id/reserved.rb', line 56

def base=(base)
  super
  reserved_words = model_class.friendly_id_config.reserved_words
  model_class.validates_exclusion_of :friendly_id, :in => reserved_words
end