module FriendlyId::Model
Instance methods that will be added to all classes using FriendlyId
.
Public Class Methods
included(model_class)
click to toggle source
# File lib/friendly_id/base.rb, line 247 def self.included(model_class) return if model_class.respond_to?(:friendly) end
Public Instance Methods
dup()
click to toggle source
Clears slug on duplicate records when calling `dup`.
Calls superclass method
# File lib/friendly_id/base.rb, line 271 def dup super.tap { |duplicate| duplicate.slug = nil if duplicate.respond_to?("slug=") } end
friendly_id()
click to toggle source
Get the instance's friendly_id.
# File lib/friendly_id/base.rb, line 257 def friendly_id send friendly_id_config.query_field end
friendly_id_config()
click to toggle source
Convenience method for accessing the class method of the same name.
# File lib/friendly_id/base.rb, line 252 def friendly_id_config self.class.friendly_id_config end
to_param()
click to toggle source
Either the friendly_id
, or the numeric id cast to a string.
Calls superclass method
# File lib/friendly_id/base.rb, line 262 def to_param if friendly_id_config.routes == :friendly friendly_id.presence.to_param || super else super end end