2010-07-27 81 views
2

有一個工作的應用程序與Rails 3.0.0beta4和剛剛更新到RC。得到一個新的奇怪的錯誤。出於某種原因,當我嘗試:Rails 3.0.0 RC ActionController :: RoutingError「沒有路由匹配」

<%= link_to "test", user %> 

用戶路由作爲資源:用戶但它抱怨沒有路線「行動=>消滅」儘管我甚至試圖鏈接來破壞:

ActionController::RoutingError in Main#index 
    No route matches {:action=>"destroy", :controller=>"users", :id=>#<User...>} 

對於參考我使用 紅寶石1.8.7(2009-06-12 PATCHLEVEL 174)[萬向darwin10.0]

路線很簡單:

resources :users 

運行rake路線返回正確的東西:

      GET /users/:id(.:format)        {:controller=>"users", :action=>"show"} 
          PUT /users/:id(.:format)        {:controller=>"users", :action=>"update"} 
         user DELETE /users/:id(.:format)        {:controller=>"users", :action=>"destroy"} 
       edit_user GET /users/:id/edit(.:format)       {:controller=>"users", :action=>"edit"} 

我生成與腳手架testrails應用程序,爲用戶和它工作得很好,所以一定有什麼東西在這裏全部跟蹤。我很難...

actionpack (3.0.0.rc) lib/action_dispatch/routing/route_set.rb:398:in `generate' 
actionpack (3.0.0.rc) lib/action_dispatch/routing/route_set.rb:450:in `generate' 
actionpack (3.0.0.rc) lib/action_dispatch/routing/route_set.rb:478:in `url_for' 
actionpack (3.0.0.rc) lib/action_dispatch/routing/url_for.rb:132:in `url_for' 
actionpack (3.0.0.rc) lib/action_view/helpers/url_helper.rb:99:in `url_for' 
actionpack (3.0.0.rc) lib/action_dispatch/routing/route_set.rb:195:in `game_path' 
actionpack (3.0.0.rc) lib/action_dispatch/routing/polymorphic_routes.rb:114:in `send' 
actionpack (3.0.0.rc) lib/action_dispatch/routing/polymorphic_routes.rb:114:in `polymorphic_url' 
actionpack (3.0.0.rc) lib/action_dispatch/routing/polymorphic_routes.rb:120:in `polymorphic_path' 
actionpack (3.0.0.rc) lib/action_view/helpers/url_helper.rb:103:in `url_for' 
actionpack (3.0.0.rc) lib/action_view/helpers/url_helper.rb:236:in `link_to' 
app/views/main/index.html.erb:10:in `_app_views_main_index_html_erb__58309089_2173261620_0' 
app/views/main/index.html.erb:8:in `each' 
app/views/main/index.html.erb:8:in `_app_views_main_index_html_erb__58309089_2173261620_0' 
actionpack (3.0.0.rc) lib/action_view/template.rb:135:in `send' 
actionpack (3.0.0.rc) lib/action_view/template.rb:135:in `render' 
activesupport (3.0.0.rc) lib/active_support/notifications.rb:54:in `instrument' 
actionpack (3.0.0.rc) lib/action_view/template.rb:127:in `render' 
actionpack (3.0.0.rc) lib/action_view/render/rendering.rb:59:in `_render_template' 
activesupport (3.0.0.rc) lib/active_support/notifications.rb:52:in `instrument' 
activesupport (3.0.0.rc) lib/active_support/notifications/instrumenter.rb:21:in `instrument' 
activesupport (3.0.0.rc) lib/active_support/notifications.rb:52:in `instrument' 
actionpack (3.0.0.rc) lib/action_view/render/rendering.rb:56:in `_render_template' 
actionpack (3.0.0.rc) lib/action_view/render/rendering.rb:26:in `render' 
actionpack (3.0.0.rc) lib/abstract_controller/rendering.rb:114:in `_render_template' 
actionpack (3.0.0.rc) lib/abstract_controller/rendering.rb:108:in `render_to_body' 
actionpack (3.0.0.rc) lib/action_controller/metal/renderers.rb:47:in `render_to_body' 
actionpack (3.0.0.rc) lib/action_controller/metal/compatibility.rb:55:in `render_to_body' 
actionpack (3.0.0.rc) lib/abstract_controller/rendering.rb:101:in `render_to_string' 
actionpack (3.0.0.rc) lib/abstract_controller/rendering.rb:92:in `render' 
actionpack (3.0.0.rc) lib/action_controller/metal/rendering.rb:17:in `render' 
actionpack (3.0.0.rc) lib/action_controller/metal/instrumentation.rb:40:in `render' 
activesupport (3.0.0.rc) lib/active_support/core_ext/benchmark.rb:5:in `ms' 
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/benchmark.rb:308:in `realtime' 
activesupport (3.0.0.rc) lib/active_support/core_ext/benchmark.rb:5:in `ms' 
actionpack (3.0.0.rc) lib/action_controller/metal/instrumentation.rb:40:in `render' 
actionpack (3.0.0.rc) lib/action_controller/metal/instrumentation.rb:78:in `cleanup_view_runtime' 
activerecord (3.0.0.rc) lib/active_record/railties/controller_runtime.rb:15:in `cleanup_view_runtime' 
actionpack (3.0.0.rc) lib/action_controller/metal/instrumentation.rb:39:in `render' 
actionpack (3.0.0.rc) lib/action_controller/metal/implicit_render.rb:10:in `default_render' 
actionpack (3.0.0.rc) lib/action_controller/metal/implicit_render.rb:5:in `send_action' 
actionpack (3.0.0.rc) lib/abstract_controller/base.rb:136:in `process_action' 
actionpack (3.0.0.rc) lib/action_controller/metal/rendering.rb:11:in `process_action' 
actionpack (3.0.0.rc) lib/abstract_controller/callbacks.rb:18:in `process_action' 
activesupport (3.0.0.rc) lib/active_support/callbacks.rb:439:in `_run__1683250185__process_action__199225275__callbacks' 
activesupport (3.0.0.rc) lib/active_support/callbacks.rb:404:in `send' 
activesupport (3.0.0.rc) lib/active_support/callbacks.rb:404:in `_run_process_action_callbacks' 
activesupport (3.0.0.rc) lib/active_support/callbacks.rb:93:in `send' 
activesupport (3.0.0.rc) lib/active_support/callbacks.rb:93:in `run_callbacks' 
actionpack (3.0.0.rc) lib/abstract_controller/callbacks.rb:17:in `process_action' 
actionpack (3.0.0.rc) lib/action_controller/metal/instrumentation.rb:30:in `process_action' 
activesupport (3.0.0.rc) lib/active_support/notifications.rb:52:in `instrument' 
activesupport (3.0.0.rc) lib/active_support/notifications/instrumenter.rb:21:in `instrument' 
activesupport (3.0.0.rc) lib/active_support/notifications.rb:52:in `instrument' 
actionpack (3.0.0.rc) lib/action_controller/metal/instrumentation.rb:29:in `process_action' 
actionpack (3.0.0.rc) lib/action_controller/metal/rescue.rb:17:in `process_action' 
actionpack (3.0.0.rc) lib/abstract_controller/base.rb:105:in `process' 
actionpack (3.0.0.rc) lib/abstract_controller/rendering.rb:40:in `process' 
actionpack (3.0.0.rc) lib/action_controller/metal.rb:133:in `dispatch' 
actionpack (3.0.0.rc) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch' 
actionpack (3.0.0.rc) lib/action_controller/metal.rb:173:in `action' 
actionpack (3.0.0.rc) lib/action_dispatch/routing/route_set.rb:62:in `call' 
actionpack (3.0.0.rc) lib/action_dispatch/routing/route_set.rb:62:in `dispatch' 
actionpack (3.0.0.rc) lib/action_dispatch/routing/route_set.rb:27:in `call' 
rack-mount (0.6.9) lib/rack/mount/route_set.rb:148:in `call' 
rack-mount (0.6.9) lib/rack/mount/code_generation.rb:89:in `recognize' 
rack-mount (0.6.9) lib/rack/mount/code_generation.rb:66:in `optimized_each' 
rack-mount (0.6.9) lib/rack/mount/code_generation.rb:88:in `recognize' 
rack-mount (0.6.9) lib/rack/mount/route_set.rb:139:in `call' 
actionpack (3.0.0.rc) lib/action_dispatch/routing/route_set.rb:489:in `call' 
actionpack (3.0.0.rc) lib/action_dispatch/middleware/head.rb:14:in `call' 
rack (1.2.1) lib/rack/methodoverride.rb:24:in `call' 
actionpack (3.0.0.rc) lib/action_dispatch/middleware/params_parser.rb:21:in `call' 
actionpack (3.0.0.rc) lib/action_dispatch/middleware/flash.rb:177:in `call' 
actionpack (3.0.0.rc) lib/action_dispatch/middleware/session/abstract_store.rb:149:in `call' 
actionpack (3.0.0.rc) lib/action_dispatch/middleware/cookies.rb:268:in `call' 
activerecord (3.0.0.rc) lib/active_record/query_cache.rb:32:in `call' 
activerecord (3.0.0.rc) lib/active_record/connection_adapters/abstract/query_cache.rb:28:in `cache' 
activerecord (3.0.0.rc) lib/active_record/query_cache.rb:12:in `cache' 
activerecord (3.0.0.rc) lib/active_record/query_cache.rb:31:in `call' 
actionpack (3.0.0.rc) lib/action_dispatch/middleware/callbacks.rb:46:in `call' 
activesupport (3.0.0.rc) lib/active_support/callbacks.rb:410:in `_run_call_callbacks' 
actionpack (3.0.0.rc) lib/action_dispatch/middleware/callbacks.rb:44:in `call' 
rack (1.2.1) lib/rack/sendfile.rb:107:in `call' 
actionpack (3.0.0.rc) lib/action_dispatch/middleware/remote_ip.rb:48:in `call' 
actionpack (3.0.0.rc) lib/action_dispatch/middleware/show_exceptions.rb:48:in `call' 
railties (3.0.0.rc) lib/rails/rack/logger.rb:13:in `call' 
rack (1.2.1) lib/rack/runtime.rb:17:in `call' 
activesupport (3.0.0.rc) lib/active_support/cache/strategy/local_cache.rb:72:in `call' 
rack (1.2.1) lib/rack/lock.rb:11:in `call' 
rack (1.2.1) lib/rack/lock.rb:11:in `synchronize' 
rack (1.2.1) lib/rack/lock.rb:11:in `call' 
actionpack (3.0.0.rc) lib/action_dispatch/middleware/static.rb:30:in `call' 
railties (3.0.0.rc) lib/rails/application.rb:168:in `call' 
railties (3.0.0.rc) lib/rails/application.rb:77:in `send' 
railties (3.0.0.rc) lib/rails/application.rb:77:in `method_missing' 
railties (3.0.0.rc) lib/rails/rack/log_tailer.rb:15:in `call' 
rack (1.2.1) lib/rack/content_length.rb:13:in `call' 
rack (1.2.1) lib/rack/handler/webrick.rb:52:in `service' 
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service' 
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run' 
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread' 
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:162:in `start' 
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread' 
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:95:in `start' 
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:92:in `each' 
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:92:in `start' 
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:23:in `start' 
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:82:in `start' 
rack (1.2.1) lib/rack/handler/webrick.rb:13:in `run' 
rack (1.2.1) lib/rack/server.rb:213:in `start' 
railties (3.0.0.rc) lib/rails/commands/server.rb:65:in `start' 
railties (3.0.0.rc) lib/rails/commands.rb:30 
railties (3.0.0.rc) lib/rails/commands.rb:27:in `tap' 
railties (3.0.0.rc) lib/rails/commands.rb:27 
script/rails:6:in `require' 
script/rails:6 

難道是從這些提交? http://github.com/rails/rails/commit/a1e795f554e07476f1084a0c76cb8b033d1d0b0c

幫助非常感謝!

回答

2

好吧繼承人的交易。我調查了相應的代碼,它是由兩件事引起的。這個問題實際上是因爲我有我的to_param設置如下:

def to_param 
    id + '/' + title.parameterize 
end 

我需要保持與非Rails應用程序舊網址的兼容性,因此「/」而不是通常的 - 。

的解決方法是用「%2F」

相關承諾,以取代「/」:http://github.com/rails/rails/commit/622092d33e8d326217ab1ed6138e2c572c95b8ba

0

您遇到的問題是,「/」是一個航線分離,所以爲了匹配你需要你的路線,看起來像

match 'users/:id/:slug', :to=>"users#show" 

要麼,或逃避「/」到「%2F」如你所說

+0

其實我在我的路線中也是這樣,但'%2F'仍然需要修復它。它在beta4以前工作,但在RC他們改變了URL解析我相信url_for或路由。 – 2010-07-29 18:07:28

0

我嘗試這樣做,在Rails 3的工作對我來說:

match "/:login" => "users#show_by_login", :as => 'show_user', :constraints => {:login => /.*/} 
相關問題