繁体   English   中英

使用rails link_to helper锚标记时,URL中会添加不必要的字符

[英]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.

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