Module: FriendlyId::History::FinderMethods

Includes:
FinderMethods
Defined in:
lib/friendly_id/history.rb

Instance Method Summary collapse

Methods included from FinderMethods

#exists?, #find, #find_by_friendly_id, #potential_primary_key?, #raise_not_found_exception

Instance Method Details

#exists_by_friendly_id?(id) ⇒ Boolean

Returns:

  • (Boolean)

88
89
90
# File 'lib/friendly_id/history.rb', line 88

def exists_by_friendly_id?(id)
  super || joins(:slugs).where(slug_history_clause(id)).exists?
end

#first_by_friendly_id(id) ⇒ Object (private)


94
95
96
# File 'lib/friendly_id/history.rb', line 94

def first_by_friendly_id(id)
  super || slug_table_record(id)
end

#slug_history_clause(id) ⇒ Object (private)


102
103
104
# File 'lib/friendly_id/history.rb', line 102

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) ⇒ Object (private)


98
99
100
# File 'lib/friendly_id/history.rb', line 98

def slug_table_record(id)
  select(quoted_table_name + '.*').joins(:slugs).where(slug_history_clause(id)).order(Slug.arel_table[:id].desc).first
end