【发布时间】:2013-05-07 11:19:11
【问题描述】:
我有以下 javascript,它接受 2 个变量(chapterid 和 txt)并将它们用作 url 中的参数。 'txt' 来自用户选择。
我的问题:当用户选择中有句点时,routes.rb 文件会出现匹配 url 的问题,或者可能会忽略句点之后的所有内容。
例子:
routes.rb
match "readers/chapannotations/new/:chapterid/:selection/" => "readers#newchapannotation"
javascript
url = '/readers/chapannotations/new/' + chapterid + '/' + txt + '/';
console.log(url);
window.location = url;
txt = 'O Arjuna.'
URL that opens: http://mysite.com/readers/chapannotations/new/5/O%20Arjuna./
这会导致没有 URL 被打开,因为在 routes.rb 中没有匹配的 URL。我相信这是因为“。”在 txt 的末尾。
txt = '阿朱那' http://mysite.com/readers/chapannotations/new/5/O%20Arjuna/
这个网址打开就好了,我相信是因为没有句号。
【问题讨论】:
标签: ruby-on-rails url routing