我在搞乱Rack::Affiliates但我不知道它是否适用于开发环境中的域 localhost。
1º 这是我在application.rb
文件中的配置:
config.middleware.use Rack::Affiliates, {:param => 'aff_id', :ttl => 6.months, :domain => '.localhost'}
2º我发送一封带有链接和参数的电子邮件,aff_id
例如:
<%= link_to "accept invite", new_user_registration_url(:aff_id => @user.id) %>
3º 在根作用中:
def index
if request.env['affiliate.tag'] && affiliate = User.find_by_affiliate_tag(request.env['affiliate.tag'])
logger.info "Halo, referral! You've been referred here by #{affiliate.name} from #{request.env['affiliate.from']} @ #{Time.at(env['affiliate.time'])}"
else
logger.info "We're glad you found us on your own!"
end
respond_to do |format|
format.html
end
end
我在控制台上收到消息:
We're glad you found us on your own!
我究竟做错了什么?
谢谢!