Class: Caboose::PermanentRedirect

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/caboose/permanent_redirect.rb

Class Method Summary collapse

Class Method Details

.match(site_id, uri) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'app/models/caboose/permanent_redirect.rb', line 15

def self.match(site_id, uri)    
  Caboose::PermanentRedirect.where(:site_id => site_id).reorder(:priority).all.each do |pr|      
    if pr.is_regex
      return uri.gsub(/#{pr.old_url}/, pr.new_url) if uri =~ /#{pr.old_url}/ 
    else                
      return pr.new_url if uri == pr.old_url
    end
  end
  return false
end