module FriendlyId::ActiveRecord2::SimpleModel

Public Class Methods

included(base) click to toggle source
# File lib/friendly_id/active_record2/simple_model.rb, line 108
def self.included(base)
  base.class_eval do
    column = friendly_id_config.column
    validate :validate_friendly_id
    validates_presence_of column
    validates_length_of column, :maximum => friendly_id_config.max_length
    after_update :update_scopes
    extend FinderMethods
    include DeprecatedMethods
  end
end

Public Instance Methods

best_id()
Alias for: friendly_id
friendly_id() click to toggle source

Returns the friendly_id.

# File lib/friendly_id/active_record2/simple_model.rb, line 126
def friendly_id
  send friendly_id_config.column
end
Also aliased as: best_id
friendly_id_status() click to toggle source

Get the {FriendlyId::Status} after the find has been performed.

# File lib/friendly_id/active_record2/simple_model.rb, line 121
def friendly_id_status
  @friendly_id_status ||= Status.new :record => self
end
to_param() click to toggle source

Returns the friendly id, or if none is available, the numeric id.

# File lib/friendly_id/active_record2/simple_model.rb, line 132
def to_param
  (friendly_id || id).to_s
end