![](/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.