Sha256: 2744986fd4e5aa074799f430f5443870fdfca6bdad9e137adef93826c94e6d2a
Contents?: true
Size: 650 Bytes
Versions: 4
Compression:
Stored size: 650 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 if diff = changes[friendly_id_config.query_field] diff.first else friendly_id.present? ? friendly_id : id.to_s end end end end
Version data entries
4 entries across 4 versions & 1 rubygems