2010-11-24 59 views
0

路由錯誤我已經在我的路線文件下列導軌上的有效途徑

rake routes | grep stop 
stop_timelog POST /timelogs/:id/stop(.:format)  {:action=>"stop", :controller=>"timelogs"} 

然而,張貼到一個請求時我看到的網址:

Started POST "/timelogs/325/stop" for 188.220.17.64 at Wed Nov 24 02:22:22 -0800 2010 
ActionController::RoutingError (No route matches "/timelogs/325/stop"): 

所有這些看起來應該可以工作,但事實並非如此。這裏可能是什麼問題?

+0

你有沒有想過這個?我有同樣的問題:http://stackoverflow.com/questions/5081153/rails-routing-what-am-i-missing – 2011-02-22 17:12:42

回答

0

其實,當你試圖與存在的資源(票)來發送表單軌在默認情況下將發出PUT的要求,所以你應該設置:method => :post清除或更改航線,從

post :resolve, :on => :member 

put :resolve, :on => :member 
0

我看到您粘貼的路線沒有問題,並且驗證了他們在臨時應用中爲我工作。

Started POST "/timelogs/123/stop" for 127.0.0.1 at 2010-11-24 11:49:25 +0000 
    Processing by TimelogsController#stop as */* 
    Parameters: {"a"=>"b", "id"=>"123"} 
Rendered text template (0.0ms) 
Completed 200 OK in 60ms (Views: 59.9ms | ActiveRecord: 0.0ms) 

也許你的routes.rb中的其他內容在這裏有衝突嗎?