module TheFriendlyId::Base::ClassMethods
Public Instance Methods
friendly_first(id)
click to toggle source
# File lib/the_friendly_id.rb, line 113 def friendly_first id friendly_where(id).first end
friendly_where(id)
click to toggle source
# File lib/the_friendly_id.rb, line 97 def friendly_where id if TheFriendlyId::Base.int?(id) where(id: id) elsif id.is_a? Array ids = id.map(&:to_slug_param) where(slug: ids) elsif TheFriendlyId::Base.friendly?(id) where(friendly_id: id) elsif TheFriendlyId::Base.short?(id) by_slug = where(slug: id.to_slug_param) by_slug.present? ? by_slug : where(slug: id.to_slug_param) else where(slug: id.to_slug_param) end end