带有句点(或句号)的 Rails 查询字符串。
我目前正在尝试掌握 RoR。我正在将两个字符串传递到我的控制器中。一个是随机的十六进制字符串,另一个是电子邮件。该项目用于对数据库进行简单的电子邮件验证。我遇到的问题是,当我输入如下内容来测试我的页面时:
http://signup.testsite.local/confirm/da2fdbb49cf32c6848b0aba0f80fb78c/bob.villa@gmailcom
我在 :email
的参数哈希中得到的只是 'bob'
。我将 gmail
和 com
之间的 .
保留掉,因为这会导致匹配根本不起作用。
我的路由匹配如下:
match "confirm/:code/:email" => "confirm#index"
这看起来很简单,足以满足我的需要。我很难弄清楚这笔交易是什么,甚至如何寻找答案。任何帮助或指导将不胜感激。
I am currently trying to get a handle on RoR. I am passing in two strings into my controller. One is a random hex string and the other is an email. The project is for a simple email verification on a database. The problem I am having is when I enter something like below to test my page:
http://signup.testsite.local/confirm/da2fdbb49cf32c6848b0aba0f80fb78c/bob.villa@gmailcom
All I am getting in my params hash of :email
is 'bob'
. I left the .
between gmail
and com
out because that would cause the match to not work at all.
My routing match is as follows:
match "confirm/:code/:email" => "confirm#index"
Which seems simple enough for what I need. I am having a hard time trying to figure out what the deal is and really how to even search for an answer. Any help or guidance would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
另外,我认为在这里设置
get
方法会更好Also it would be better to set
get
method here, I think您的问题是 Rails 试图将
.villa@gmailcom
解释为格式规范(例如.html
或.json
)。 AFAIK,标准的解决方法(或者至少是我使用的方法)是将其添加到您的路线中:这会欺骗 Rails 不试图聪明地了解
:email
包含的内容。对于您在谷歌上搜索“@”或“.”找不到任何东西,我并不感到惊讶。没有做任何有用的事情。
Your problem is that Rails is trying to interpret
.villa@gmailcom
as a format specification (such as.html
or.json
). AFAIK, the standard work around (or at least the one I use) is to add this to your route:This tricks Rails into not trying to be clever about what
:email
contains.I'm not surprised that you couldn't find anything, googling for "@" or "." doesn't do anything useful.