2011-08-15 84 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