2010-09-17 91 views
0
<%= link_to 'Testing', wak_path %> 

*This requires a routes: match 'wak', :to => 'home#wak' 

他們是否把這個出來的軌道3.0或發生了什麼?Ruby on Rails 3.0爲什麼這兩個輸出兩個不同的東西?

<%= link_to 'Testing, :controller=>:home,:actions=>:wak %> 

但在視圖中,我得到兩個不同的代碼,頂部的方法工作,雖然第二種方法沒有相同的行爲。爲什麼是這樣?

我只是做了一些測試,這就是我改變參數時所提出的。和我得到的輸出。

<%= link_to 'hello', test_path, :remote=>true%> 
<a href="/test" data-remote="true">hello</a> 

<%= link_to 'hello', {:controller=>:home,:actions=>:test}, :remote=>true%> 
<a href="/home/index?actions=test" data-remote="true">hello</a> 


<%= link_to 'hello', :url=>{:controller=>:home,:actions=>:test}, :remote=>true%> 
<a href="/home/index?url[controller]=home&amp;url[actions]=test&amp;remote=true">hello</a> 

回答

0

:行動而不是:行動

1

在第二種方法中,您忘記關閉測試報價。它應該是

<%= link_to 'Testing', :controller=>:home,:actions=>:wak %> 

在Rails 3能正常工作的第二個方法,你也可以通過在命令行耙路線寫檢查路線和檢查每個路徑的輔助方法與控制器相匹配 - 行動。

+0

它仍然沒有產生應該預期的。我已經印上了我所得到的。 – RoR 2010-09-17 23:03:52

0

測試後缺少報價?

+0

我希望這是原因。 – RoR 2010-09-17 23:04:20

相關問題