Module: FriendlyId::History::FinderMethods
- Defined in:
 - lib/friendly_id/history.rb
 
Overview
Adds a finder that explictly uses slugs from the slug table.
Instance Method Summary (collapse)
- 
  
    
      - (Boolean) exists?(id = false) 
    
    
  
  
  
  
  
  
  
  
  
    
Search for a record in the slugs table using the specified slug.
 - 
  
    
      - (Object) find_one(id) 
    
    
  
  
  
  
  
  
  
  
  
    
Search for a record in the slugs table using the specified slug.
 - 
  
    
      - (Object) with_old_friendly_id(slug) {|sluggable_id| ... }
    
    
  
  
  
  
  private
  
  
  
  
    
Accepts a slug, and yields a corresponding sluggable_id into the block.
 
Instance Method Details
- (Boolean) exists?(id = false)
Search for a record in the slugs table using the specified slug.
      98 99 100 101 102 103  | 
    
      # File 'lib/friendly_id/history.rb', line 98 def exists?(id = false) return super if id.unfriendly_id? exists_without_friendly_id?(@klass.friendly_id_config.query_field => id) or with_old_friendly_id(id) {|x| exists_without_friendly_id?(x)} or exists_without_friendly_id?(id) end  | 
  
- (Object) find_one(id)
Search for a record in the slugs table using the specified slug.
      90 91 92 93 94 95  | 
    
      # File 'lib/friendly_id/history.rb', line 90 def find_one(id) return super(id) if id.unfriendly_id? where(@klass.friendly_id_config.query_field => id).first or with_old_friendly_id(id) {|x| find_one_without_friendly_id(x)} or find_one_without_friendly_id(id) end  | 
  
- (Object) with_old_friendly_id(slug) {|sluggable_id| ... } (private)
Accepts a slug, and yields a corresponding sluggable_id into the block.
      108 109 110 111 112 113  | 
    
      # File 'lib/friendly_id/history.rb', line 108 def with_old_friendly_id(slug, &block) sql = "SELECT sluggable_id FROM #{Slug.quoted_table_name} WHERE sluggable_type = %s AND slug = %s" sql = sql % [@klass.base_class.to_s, slug].map {|x| connection.quote(x)} sluggable_id = connection.select_values(sql).first yield sluggable_id if sluggable_id end  |