Skip to content

voke/redirector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

74 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Redirector

Redirector allows you to easily generate a redirect action for a specific resource.

class Product
  belongs_to :store
  delegate :parameterize, to: :name
  redirect_with base: -> x { x.store.affiliate_uri }, path: :url, epi: :parameterize
end

Define redirect routes:

Foobar::Application.routes.draw do
  redirect_for :products
end

Generate the redirect link:

<%= link_for 'Go to product', redirect_product_path(@product) %>

Or use the view helper:

<%= redirect_link_to 'Go to product', @product %>

which generates following html:

<a href="/products/to_param/redirect" data-external="true" rel="nofollow">Go to product</a>

Add tracking url:

Redirect to the page through a tracking url. The url parameter is unescaped.

config/redirector.rb

Redirector.setup do |config|
	config.tracking_url = "http://example.com/track/{url}"
end

About

Generate tracking links for affiliate networks

Resources

Stars

Watchers

Forks

Packages

No packages published