简体   繁体   English

Rails路线-特定网址

[英]Rails Route - specific URL

I want to implement a tracking pixel for inside an email. 我想为电子邮件内部实现跟踪像素。

The tracking pixel URL should look something like this: 跟踪像素网址应如下所示:

http://example.com/__track.gif?id=XXXXXXX&u=XXXXX

Questions: 问题:

  1. How do I create a route specifically for that? 如何为此专门创建一条路线?
  2. while it says it's .gif, I don't actually want a gif file, as I want a rails controller to get called and be able to run a few methods when called, using the url params. 虽然它说是.gif,但实际上我并不想要gif文件,因为我希望使用url参数调用Rails控制器并能够在调用时运行一些方法。

Thoughts? 有什么想法吗?

Put the following in your routes.rb file: 将以下内容放入您的routes.rb文件中:

match "/_track.gif" => "controller_name#action_name"

Replacing controller_name & action_name with those appropriate. 用适当的值替换controller_nameaction_name

I recommend you read over the Rails Guide for routing , as match is noted in the very first section. 我建议您仔细阅读《 Rails布线指南》 ,因为match在第一部分match已提到。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM