学习ROR,遭遇“Routing Error”了,请指点,该如何处理

学习ROR,遭遇“Routing Error”了,请指点
这段时间看《Web开发敏捷之道——应用Rails进行敏捷Web开发(第3版)》学习ror,版本跟书上的一样,rubu是1.8.6,rails是2.2.2。
  自己做其他ror应用的时候,controller和action都有了(depot没这个问题),但是浏览器里面老是提示如下:

Java code

Routing Error

No route matches "/xxx/yyy" with {:method=>:get}



我的routes.rb如下:
Java code


ActionController::Routing::Routes.draw do |map|
  
  map.resources :products

  map.resources :products

  map.resources :products

  map.connect ':controller/:action/:id';
  map.connect ':controller/:action/:id.:format';
end



google后有一个说法让加上:
Java code

map.resources :Xxx, :collection => { :yyy => :get };



之后确实能行了

请问:
1、因之前按第2版做同样的应用的时候没出现过这问题,routing error是rails 2.0新增加了规则所致吗?

2、按上述那个语句,在{ }里要每个action写一次,有什么通配符之类的方式吗

3、我的url明明符合map.connect的规则,为什么老是routing error?map.resource和map.connect之间是否有什么特别的规则需要协调的呢?

请指点,谢谢


------解决方案--------------------
map.resources :xxx, :collection => { :yyy => :get };

说明你使用的restful路由,应该是使用scaffold的生成的吧,rails支持了REST路由,如果你的routes.rb中包含了 map.resources :products
相当于默认支持了
 map.resources :products,:collection => { :index => :get,:new=>:get,:create:=>:post},:member=>{:edit=>:get,:update=>:put,:destory=>:delete,:show=>:get}

如果想支持xxx/yyy需要在在collection中添加,:collection => { :yyy => :get };


如果你想和之前一样不需要restful的路由的话,只需要注释掉

map.resources :xxx

xxx代表什么,你懂得吧,看你的路由写了3个

  
map.resources :products

map.resources :products

map.resources :products


我想你应该是products后面添加自己的方法吧.

希望你看下这篇文章.http://guides.rubyonrails.org/routing.html
大家一起学习,你遇到的问题,也是我当初遇到的问题.