Sha256: 21de74dddda95ed65ddceb406c31a90c7ff91b2a1d3d162388a2db92f3b50a85

Contents?: true

Size: 715 Bytes

Versions: 8

Compression:

Stored size: 715 Bytes

Contents

module FriendlyId::NonSluggableInstanceMethods

  attr :found_using_friendly_id

  # Was the record found using one of its friendly ids?
  def found_using_friendly_id?
    @found_using_friendly_id
  end

  # Was the record found using its numeric id?
  def found_using_numeric_id?
    !@found_using_friendly_id
  end
  alias has_better_id? found_using_numeric_id?

  # Returns the friendly_id.
  def friendly_id
    send friendly_id_options[:column]
  end
  alias best_id friendly_id

  # Returns the friendly id, or if none is available, the numeric id.
  def to_param
    friendly_id.to_s || id.to_s
  end

  private

  def found_using_friendly_id=(value) #:nodoc#
    @found_using_friendly_id = value
  end

end

Version data entries

8 entries across 8 versions & 4 rubygems

Version Path
dougcole-friendly_id-2.0.2 lib/friendly_id/non_sluggable_instance_methods.rb
dougcole-friendly_id-2.0.3 lib/friendly_id/non_sluggable_instance_methods.rb
norman-friendly_id-2.0.1 lib/friendly_id/non_sluggable_instance_methods.rb
norman-friendly_id-2.0.2 lib/friendly_id/non_sluggable_instance_methods.rb
alancse-friendly_id-2.0.1 lib/friendly_id/non_sluggable_instance_methods.rb
friendly_id-1.9.9 lib/friendly_id/non_sluggable_instance_methods.rb
friendly_id-2.0.1 lib/friendly_id/non_sluggable_instance_methods.rb
friendly_id-2.0.0 lib/friendly_id/non_sluggable_instance_methods.rb