2011-08-14 40 views
20

我有在Rails link_to方法滑軌:錨選項和的link_to

link_to("feedback", meetings_url(:anchor => "sometext")) 

=>以上代碼生成:

<a href="/p/meeting/?scroll_to=sometext">feedback</a> 

我認爲錨是應該在前面加上一個散列參數,則像這個:

/p/meeting/#sometext 
+1

這不是正常的Rails行爲,您應該檢查一些gem或插件是否替換標準'link_to'助手。 –

+0

是的,你是對的。我有一個覆蓋默認行爲的寶石 –

回答

29

我剛剛在控制檯嘗試過,我得到了#anchor

irb(main):009:0> include Rails.application.routes.url_helpers 
=> Object 
irb(main):010:0> default_url_options[:host] = "localhost" 
=> "localhost" 
irb(main):011:0> profiles_url(:anchor => "moo") 
=> "http://localhost/profiles#moo" 
irb(main):012:0> 

您使用的是哪種版本的導軌?做喲也許有一個重載你的link_to助手的寶石或插件?您可以創建一個空的rails應用程序,並嘗試上述測試以查看是否有其他內容導致它。

+2

說傑克..我想​​通了。有一些寶石覆蓋我的網址幫手。 ! –