I would like to add a parameter to each URL in my Rails 2.3.10 application. I played with the default_url_options
but I want the parameter to be visible in the URL. Something like:
http://<server>/posts?token=XYZ
I'm building an affilate tracking system and I want people to share the link and be able to track who's link was used later when someone clicks it (to give points to the guy who shared the link). Any hints how I can add a visible parameter in each URL used in the application?
Thanks!
Rewrite url_for
module ActionView::Helpers::UrlHelper
def url_for options
options.merge! {:token => generate_token}
super
end
end
or just add this to your application.rb
file
config.default_url_options += {:token => proc{generate_token}}