Module: Slugged::Finders

Defined in:
lib/slugged/finders.rb

Instance Method Summary collapse

Instance Method Details

#find_using_slug(slug) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'lib/slugged/finders.rb', line 4

def find_using_slug(slug)
  slug = slug.to_s
  value = nil
  value ||= find_by_id(slug.to_i) if slug =~ /\A\d+\Z/
  value ||= with_cached_slug(slug).first
  value ||= find_using_slug_history(slug) if use_slug_history
  value.found_via_slug = slug if value.present?
  value
end

#find_using_slug!(slug) ⇒ Object



14
15
16
# File 'lib/slugged/finders.rb', line 14

def find_using_slug!(slug)
  find_using_slug(slug) or raise ActiveRecord::RecordNotFound
end