rails 3 rake路由不起作用,没有路由显示为输出 [英] rails 3 rake routes not working, no routes shown as output

查看:110
本文介绍了rails 3 rake路由不起作用,没有路由显示为输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我执行

bundle exec rake routes --trace

输出为:

NOTE: Gem.source_index is deprecated, use Specification. It will be removed on or after 2011-11-01.
Gem.source_index called from /usr/local/rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.10/lib/bundler/shared_helpers.rb:3.
NOTE: Gem.source_index is deprecated, use Specification. It will be removed on or after 2011-11-01.
Gem.source_index called from /usr/local/rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.10/lib/bundler/source.rb:162.
NOTE: Gem::SourceIndex#each is deprecated with no replacement. It will be removed on or after 2011-11-01.
Gem::SourceIndex#each called from /usr/local/rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.10/lib/bundler/source.rb:162.
NOTE: Gem.source_index is deprecated, use Specification. It will be removed on or after 2011-11-01.
Gem.source_index called from /usr/local/rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.10/lib/bundler/shared_helpers.rb:84.
NOTE: Gem.source_index is deprecated, use Specification. It will be removed on or after 2011-11-01.
Gem.source_index called from /usr/local/rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.10/lib/bundler/shared_helpers.rb:3.
NOTE: Gem.source_index is deprecated, use Specification. It will be removed on or after 2011-11-01.
Gem.source_index called from /usr/local/rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.10/lib/bundler/source.rb:162.
NOTE: Gem::SourceIndex#each is deprecated with no replacement. It will be removed on or after 2011-11-01.
Gem::SourceIndex#each called from /usr/local/rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.10/lib/bundler/source.rb:162.
NOTE: Gem.source_index is deprecated, use Specification. It will be removed on or after 2011-11-01.
Gem.source_index called from /usr/local/rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.10/lib/bundler/shared_helpers.rb:84.
WARNING: 'require 'rake/rdoctask'' is deprecated.  Please use 'require 'rdoc/task' (in RDoc 2.4.2+)' instead.
at /usr/local/rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/rdoctask.rb
** Invoke routes (first_time)
** Invoke environment (first_time)
** Invoke threadsafe:disabled (first_time)
** Execute threadsafe:disabled
** Execute environment
** Execute routes

这是我的config / routes.rb文件

and here is my config/routes.rb file

 Rails_app::Application.routes.draw do

  match '/' => 'pages#show', :id => '1-welcome-page'
  match       ':controller(/:action(/:id(.:format)))'

end

这是我的宝石清单

abstract (1.0.0)
actionmailer (3.0.3)
actionpack (3.0.3)
activemodel (3.0.3)
activerecord (3.0.3)
activeresource (3.0.3)
activesupport (3.0.3)
arel (2.0.10)
builder (3.0.0, 2.1.2)
bundler (1.0.10 ruby)
cgi_multipart_eof_fix (2.5.0)
daemons (1.1.0, 1.0.10)
erubis (2.6.6)
eventmachine (0.12.10)
fastthread (1.0.7)
gem_plugin (0.2.3)
i18n (0.6.0)
kgio (2.2.0)
mail (2.2.19)
mime-types (1.17.2)
mongrel (1.2.0.pre2)
mysql2 (0.2.7)
polyglot (0.3.3)
rack (1.2.5)
rack-mount (0.6.14)
rack-test (0.5.7)
rails (3.0.3)
railties (3.0.3)
rake (0.9.2.2)
rmagick (2.13.1)
thin (1.2.7)
thor (0.14.6)
treetop (1.4.10)
tzinfo (0.3.31)
unicorn (3.4.0)
xmpp4r (0.5)

有人知道为什么不生成路由吗?

Does anyone know why no routes are produced?

推荐答案

哇,我终于确定了路线。我认为部分问题是该应用程序是已转换为Rails 3应用程序的Rails 2应用程序。无论如何,我所做的是:

Wow, I finally got the routes working. I think part of the problem was that the app was a Rails 2 app that had been converted into a Rails 3 app. Anyway what I did was:

 1.  Made a simple Rails 3 app, and ran 'bundle exec rake routes' and I could see that that worked, so I knew the current set of libraries wasn't the problem.
 2.  Then I made the config files the same for both apps.
 3.  Also made the 'config/initializer' files the same for both apps.
 4.  Also made the 'config/environments/production.rb' file the same for both apps.
 5.  And that did the trick!

一旦我有了一个适用于耙路的简单Rails 3应用程序,我就曾尝试运行调试器针对两个应用程序的耙路径:

Once I had a simple Rails 3 app that worked for 'rake routes', I earlier tried running the debugger on rake routes for both of the apps:

 bundle exec rdebug rake routes

并逐步执行大量代码,以了解两个应用程序在何处采用不同的路径,但是由于两个应用程序之间存在很大差异,因此我

and stepped through a LOT of the code to see where the two apps took different paths, but since there was so much different between the two apps, I wasn't able to figure out where things were going wrong.

无论如何,我希望这可以帮助遇到相同问题的人。

Anyway, I hope this helps someone who runs into the same problem.

这篇关于rails 3 rake路由不起作用,没有路由显示为输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆