ruby-on-rails路由问题

时间:2011-08-15 14:49:12

标签: ruby-on-rails ruby flex ruby-on-rails-3

我有以下路线:

     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"而不会出错。

我做错了什么?提前谢谢。

1 个答案:

答案 0 :(得分:2)

当您输入http://localhost:3000/people/1.xml时,它是GET请求。

您需要提出PUT实际为POST http://localhost:3000/people/1.xml?_method=PUT

的请求

所以你需要从Flex

以某种方式提出POST请求