2011-08-15 80 views
1

我有以下途徑:的Ruby-on-軌道路線問題

 people GET /people(.:format)   {:action=>"index", :controller=>"people"} 
      POST /people(.:format)   {:action=>"create", :controller=>"people"} 
new_person GET /people/new(.:format)  {:action=>"new", :controller=>"people"} 
edit_person GET /people/:id/edit(.:format) {:action=>"edit", :controller=>"people"} 
    person GET /people/:id(.:format)  {:action=>"show", :controller=>"people"} 
      **PUT /people/:id(.:format)  {:action=>"update", :controller=>"people"}** 
      DELETE /people/:id(.:format)  {:action=>"destroy", :controller=>"people"} 

然而,當我Flex客戶端要求更新

" **<mx:HTTPService id = "update" 
url='http://localhost:3000/people/{grid.selectedItem.id}.xml?_method=put**" 

我得到的錯誤

**ActionController::RoutingError (No route matches "/people/1.xml"**. 

即使我明確地(用於故障排除)將線路轉換爲**url='http://localhost:3000/people/1.xml?_method=put",錯誤仍然存​​在。*

我可以在地址欄中輸入"http://localhost:3000/people/1.xml",沒有錯誤。

我在做什麼不正確?提前致謝。

+0

貌似基於http://stackoverflow.com/questions/在機架中的錯誤在某種程度上POST要求做3732183/rails-3-method-put-still-supposed-to-working –

+0

@Jibaly以前的解決方案似乎不起作用,部分原因是中間件在config/environment.rb中交換會導致錯誤:「未定義變量」 –

回答

2

當您輸入http://localhost:3000/people/1.xml這是GET請求。

你需要做一個PUT請求,這實際上是POST http://localhost:3000/people/1.xml ?_method=PUT

所以,你需要從Flex的

+0

感謝您的及時回覆。 flex的全文內容如下: 正如你可以看到它是一個POST請求。 –

+0

@伊詹金斯,是的,我明白了。所以Rails有些問題 – fl00r