2010-10-12 265 views
0

尝试访问我的页面时出现路由错误。Ruby on Rails路由问题

Routing Error 
No route matches "/" with {:method=>:get} 

错误日志上写着:

[4;36;1mSQL (0.1ms)[0m [0;1mSET NAMES 'utf8'[0m 
[4;35;1mSQL (0.0ms)[0m [0mSET SQL_AUTO_IS_NULL=0[0m 


Processing ApplicationController#index (for 68.116.193.166 at 2010-10-11 19:18:16) [GET] 

ActionController::RoutingError (No route matches "/" with {:method=>:get}): 
    config/initializers/mongrel.rb:62:in `dispatch_cgi' 

Rendering rescues/layout (not_found) 

通常当我看到这个我检查路由在配置/ routes.rb中定义的,它们是。所以我想通过键入它可以访问/新的,其中给了我下面的错误。

Routing Error 
No route matches **"//new"** with {:method=>:get} 

随着development.log以下

[4;36;1mSQL (0.1ms)[0m [0;1mSET NAMES 'utf8'[0m 
[4;35;1mSQL (0.0ms)[0m [0mSET SQL_AUTO_IS_NULL=0[0m 


Processing ApplicationController#index (for 68.116.193.166 at 2010-10-11 19:18:21) [GET] 

ActionController::RoutingError (No route matches "//new" with {:method=>:get}): 
config/initializers/mongrel.rb:62:in `dispatch_cgi' 

Rendering rescues/layout (not_found) 

我的设置: 的Rails:2.3.8 红宝石:1.8.7 的RubyGems:1.3.7 杂种:1.1.5

我觉得很奇怪,使用address/imgs/new返回路径“// new”。我一直在强调这几天,并找到答案无处可寻。希望有人知道如何解决这个问题,可以指出我在这里失去的东西。由于提前

+0

你可以发布'$ rake routes'的输出吗?请使用'1010'堆栈溢出格式化按钮来格式化输出,以便读取。 – SooDesuNe 2010-10-12 00:27:47

+0

不幸的是,我不得不使用justhost来处理这个问题,并且必须处理它们和cPanel,所以我的功能有限。我确实有这个稳定的工作在我的本地机器上,当我运行耙子时,一切看起来都正确。有任何想法吗? – 2010-10-12 00:46:06

+0

请向我们显示config/routes.rb文件。 – 2010-10-12 00:46:31

回答

0

这里是我的config/routes.rb中文件

ActionController::Routing::Routes.draw do |map| 
map.resources :vids 
map.resources :users 
map.resources :tasks 
map.resources :quotes 
map.resources :projects 
map.resources :products 
map.resources :permissions 
map.resources :pages 
map.resources :orders 
map.resources :imgs 
map.resources :documents 
map.resources :contents 
map.resources :contacts 
map.resources :comments 
map.resources :clients 
map.resources :addresses 
map.resources :users 
map.login "login", :controller => "user_sessions", :action => "new" 
map.logout "logout", :controller => "user_sessions", :action => "destroy" 
map.connect ':controller/:action/:id' 
map.connect ':controller/:action/:id.:format' 
end 
+0

那么根路线在哪里?因为你没有路由匹配'/'这应该是根路由。你应该有像'map.root:controller =>“something”' – PeterWong 2010-10-12 01:22:58

+0

我不能相信我错过了。我已经补充说,但现在它重新路由所有的路径。因此,如果我访问www.swinkapps.com/imgs或www.swinkapps.com/users,那么我会得到与“设置”相同的“项目”索引页。即使如果我尝试创建一个新的项目,它会给我以下错误 路由错误 没有路由与{:method =>:get}匹配“// new” – 2010-10-12 01:53:52

+0

我不认为这是他的问题。 'map.root:controller'是没有必要的。从默认routes.rb:“你可以让你的网站的根与map.root路由 - 只记得删除public/index.html。” – SooDesuNe 2010-10-12 01:55:13

0

这只是我恍然大悟,我可能能够通过确保端口包括果然WWW去的机型。 swinkapps.com:12005/imgs给了我适当的回应。有没有办法来覆盖这个,以便www.swinkapps.com:12005映射到www.swinkapps.com?