Parent

FriendlyId::Configuration

The configuration paramters passed to friendly_id will be stored in this object.

Attributes

base[RW]

The base column or method used by FriendlyId as the basis of a friendly id or slug.

For models that don't use FriendlyId::Slugged, the base is the column that is used as the FriendlyId directly. For models using FriendlyId::Slugged, the base is a column or method whose value is used as the basis of the slug.

For example, if you have a model representing blog posts and that uses slugs, you likely will want to use the "title" attribute as the base, and FriendlyId will take care of transforming the human-readable title into something suitable for use in a URL.

@param [Symbol] A symbol referencing a column or method in the model. This

value is usually set by passing it as the first argument to
{FriendlyId::Base#friendly_id friendly_id}:

@example

class Book < ActiveRecord::Base
  extend FriendlyId
  friendly_id :name
end
defaults[R]

The default configuration options.

model_class[RW]

The model class that this configuration belongs to. @return ActiveRecord::Base

Public Class Methods

new(model_class, values = nil) click to toggle source
# File lib/friendly_id/configuration.rb, line 37
def initialize(model_class, values = nil)
  @model_class = model_class
  @defaults    = {}
  set values
end

Public Instance Methods

query_field() click to toggle source

The column that FriendlyId will use to find the record when querying by friendly id.

This method is generally only used internally by FriendlyId. @return String

# File lib/friendly_id/configuration.rb, line 70
def query_field
  base.to_s
end
use(*modules) click to toggle source

Lets you specify the modules to use with FriendlyId.

This method is invoked by {FriendlyId::Base#friendly_id friendly_id} when passing the :use option, or when using {FriendlyId::Base#friendly_id friendly_id} with a block.

@example

class Book < ActiveRecord::Base
  extend FriendlyId
  friendly_id :name, :use => :slugged
end

@param [to_s,Module] *modules Arguments should be Modules, or symbols or

strings that correspond with the name of a module inside the FriendlyId
namespace. By default FriendlyId provides +:slugged+, +:history+,
+:simple_i18n+, +:globalize+, and +:scoped+.
# File lib/friendly_id/configuration.rb, line 58
def use(*modules)
  modules.to_a.flatten.compact.map do |object|
    mod = object.kind_of?(Module) ? object : FriendlyId.const_get(object.to_s.classify)
    model_class.send(:include, mod)
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.