簡體   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