Module: FriendlyId::Base

Included in:
ActiveRecordAdapter
Defined in:
lib/friendly_id.rb

Instance Method Summary collapse

Instance Method Details

#has_friendly_id(method, options = {}) ⇒ Object

Set up a model to use a friendly_id. This method accepts a hash with several possible options.

Examples:


class User < ActiveRecord::Base
  has_friendly_id :user_name
end

class Post < ActiveRecord::Base
  has_friendly_id :title, :use_slug => true, :approximate_ascii => true
end

Raises:

See Also:

Parameters:

  • The column or method that should be used as the basis of the friendly_id string.

  • (defaults to: {})

    For valid configuration options, see Configuration.



45
46
47
# File 'lib/friendly_id.rb', line 45

def has_friendly_id(method, options = {})
  raise NotImplementedError
end

#uses_friendly_id?Boolean

Does the model class use the FriendlyId plugin?

Returns:



50
51
52
# File 'lib/friendly_id.rb', line 50

def uses_friendly_id?
  respond_to? :friendly_id_config
end