module FriendlyId::History::FinderMethods

Public Instance Methods

exists_by_friendly_id?(id) click to toggle source
# File lib/friendly_id/history.rb, line 86
def exists_by_friendly_id?(id)
  joins(:slugs).where(arel_table[friendly_id_config.query_field].eq(id)).exists? || joins(:slugs).where(slug_history_clause(id)).exists?
end

Private Instance Methods

first_by_friendly_id(id) click to toggle source
# File lib/friendly_id/history.rb, line 92
def first_by_friendly_id(id)
  matching_record = where(friendly_id_config.query_field => id).first
  matching_record || slug_table_record(id)
end
slug_history_clause(id) click to toggle source
# File lib/friendly_id/history.rb, line 101
def slug_history_clause(id)
  Slug.arel_table[:sluggable_type].eq(base_class.to_s).and(Slug.arel_table[:slug].eq(id))
end
slug_table_record(id) click to toggle source
# File lib/friendly_id/history.rb, line 97
def slug_table_record(id)
  select(quoted_table_name + '.*').joins(:slugs).where(slug_history_clause(id)).first
end