Rails 3 ActionMailer: :escape => false 不起作用,raw() 也不起作用
我想将查询字符串参数附加到从 Rails 3 ActionMailer 模板生成的 URL,但与符号正在被实体转义。
<%= user_url(@user, :host => 'example.com', :foo => 'bar', :fubar => 'baz') %>
结果带有 HTML 转义符号的 URL(如预期),例如
http://example.com/user/123?foo=bar&fubar=baz
(注意它是 &
不是 &
)
我不想转义(因为它破坏了 URL)。我曾经能够添加 :escape =>; false
,但这不影响现在的结果。我尝试将查询字符串参数放入像 ?foo=bar&fubar=baz
这样的字符串中,并使用 raw()
像
<%= user_url(@user , :host => 'example.com') + raw("foo=bar&fubar=baz") %>
但这也逃脱了我的&符号。
有没有办法在 HTML 电子邮件 URL 中传递未转义的查询字符串参数?
提前致谢!
汤姆
I want to append query string parameters to URLs generated from Rails 3 ActionMailer templates, but the ampersands are being entity escaped.
<%= user_url(@user, :host => 'example.com', :foo => 'bar', :fubar => 'baz') %>
results in a URL with an HTML-escaped ampersand (as expected), like
http://example.com/user/123?foo=bar&fubar=baz
(notice it's &
not &
)
I don't want the escaping (because it breaks the URLs). I used to be able to add :escape => false
, but this doesn't affect the result now. I tried putting the query string parameters in a string like ?foo=bar&fubar=baz
and using raw()
like
<%= user_url(@user, :host => 'example.com') + raw("foo=bar&fubar=baz") %>
but this also escaped my ampersand.
Is there a way to pass unescaped query string parameters in HTML email URLs?
Thanks in advance!
Tom
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 Rails 门票中找到了这个。它被标记为“已关闭”,但从 3.1.0.rc4 开始似乎仍然是一个问题。
https://github.com/rails/rails/issues/687
编辑:我是能够通过将我的 url 帮助器包装在
raw()
中来解决此问题。例如Found this in the Rails tickets. It's marked as 'closed', but still appears to be a problem as of 3.1.0.rc4.
https://github.com/rails/rails/issues/687
EDIT: I was able to fix this by wrapping my url helper in
raw()
. E.g.