![](/img/trans.png)
[英]Is there an advantage to using link_to over the anchor tag in Rails?
[英]unnecessary characters getting added in URL when using rails link_to helper anchor tag
我试图将#xyz
添加到使用rails link_to
helper生成的链接中。
以下是我的代码:
<%= link_to('', edit_notification_path(:id => item.id,:type =>"requester_template",
:notification_type => @notification_type,:anchor => "#xyz"),
:class => 'icon-pencil-3' ) %>
但是生成的URL看起来像
email_notifications/3/edit/requester_template?notification_type=ticket#%23es
那是一个额外的%23与锚点一起添加。
我在这里做错了什么? (这里是Rails初学者)
您必须将:anchor => "#xyz"
更改为:anchor => "xyz"
。 选项:anchor
已包含#
。
尝试这个
<%= link_to('', edit_notification_path(id: item.id,type: "requester_template",
notification_type: @notification_type,anchor: "xyz"),
class: 'icon-pencil-3' ) %>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.