Sha256: 0e0f82862be00ebd7497d4c442710a94b41308fa738cbfca2d5c8c192af6902f

Contents?: true

Size: 554 Bytes

Versions: 8

Compression:

Stored size: 554 Bytes

Contents

module FriendlyId
  # Instance methods that will be added to all classes using FriendlyId.
  module Model

    attr_reader :current_friendly_id

    # Convenience method for accessing the class method of the same name.
    def friendly_id_config
      self.class.friendly_id_config
    end

    # Get the instance's friendly_id.
    def friendly_id
      send friendly_id_config.query_field
    end

    # Either the friendly_id, or the numeric id cast to a string.
    def to_param
      (friendly_id.present? ? friendly_id : id).to_s
    end
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
friendly_id-4.0.0.beta10 lib/friendly_id/model.rb
friendly_id-4.0.0.beta8 lib/friendly_id/model.rb
friendly_id-4.0.0.beta7 lib/friendly_id/model.rb
friendly_id4-4.0.0.beta6 lib/friendly_id/model.rb
friendly_id4-4.0.0.beta5 lib/friendly_id/model.rb
friendly_id4-4.0.0.beta4 lib/friendly_id/model.rb
friendly_id4-4.0.0.beta3 lib/friendly_id/model.rb
friendly_id4-4.0.0.beta1 lib/friendly_id/model.rb