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?

Instance Method Details

- (Boolean) exists_by_friendly_id?(id)

Returns:

  • (Boolean)


83
84
85
# File 'lib/friendly_id/history.rb', line 83

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

- (Object) first_by_friendly_id(id) (private)



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

def first_by_friendly_id(id)
  where(friendly_id_config.query_field => id).first ||
  select(quoted_table_name + '.*').joins(:slugs).where(slug_history_clause(id)).first
end

- (Object) slug_history_clause(id) (private)



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

def slug_history_clause(id)
  Slug.arel_table[:sluggable_type].eq(base_class.to_s).and(Slug.arel_table[:slug].eq(id))
end