2017-05-05 65 views
0

大家好,我想知道如何擺脫當我點擊我網站上的鏈接時產生的這個醜陋的網址。它看起來像這樣:link_to幫手奇怪的網址

http://www.imaaroncs.com/about?as=AboutMe&class=changeMe&controler=welcome 

我希望它只是說一下,但我不知道如何使用的link_to軌做幫手,這是我到目前爲止有:

<li class="navbar-brand"><%= link_to "About Me", class: "changeMe",controler: "welcome", as: "AboutMe", action: "about"%> 

回答

1

你發送你不需要幾個參數(那些後?被解釋爲額外的查詢參數)

<%= link_to "About Me", action: "about" %> 
+0

大。另一件事,使用動作名稱作爲描述url的方式並不常見。完美的確定,但是可能有一個從你的路線文件創建的方法。你可以通過在命令行上執行'rake routes'來查看所有的方法。該方法可能類似於'about_path',那麼這將有點硬編碼。 – Swards

0

嘗試使用字面上的散列:

<%= link_to "About Me", {class: "changeMe", controller: "welcome", as: "AboutMe", action: "about"} %> 

PS。此外,控制器中還有雙重l。你有一個。