Module: FriendlyId::Base

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

Instance Method Summary (collapse)

Instance Method Details

- (Object) has_friendly_id(method, options = {})

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

Parameters:

  • method (#to_sym)

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

  • options (Hash) (defaults to: {})

    For valid configuration options, see Configuration.

Raises:

  • (NotImplementedError)

See Also:



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

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

- (Boolean) uses_friendly_id?

Does the model class use the FriendlyId plugin?

Returns:

  • (Boolean)


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

def uses_friendly_id?
  respond_to? :friendly_id_config
end