我正在尝试运行rails server
,我看到的是这样的事情:
C:\Users\Mama i Tata>cd c:/rails_project/my_app
c:\rails_project\my_app>rails s
=> Booting WEBrick
=> Rails 3.2.6 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
c:/rails_project/my_app/config/routes.rb:1:in `<top (required)>': uninitialized
constant SampleApp (NameError)
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.6/lib/rails/applic
ation/routes_reloader.rb:40:in `block in load_paths'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.6/lib/rails/applic
ation/routes_reloader.rb:40:in `each'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.6/lib/rails/applic
ation/routes_reloader.rb:40:in `load_paths'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.6/lib/rails/applic
ation/routes_reloader.rb:16:in `reload!'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.6/lib/rails/applic
ation/routes_reloader.rb:26:in `block in updater'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.6/lib/active_
support/file_update_checker.rb:78:in `call'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.6/lib/active_
support/file_update_checker.rb:78:in `execute'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.6/lib/rails/applic
ation/routes_reloader.rb:27:in `updater'
from C:in `execute_if_updated'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.6/lib/rails/applic
ation/finisher.rb:66:in `block in <module:Finisher>'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.6/lib/rails/initia
lizable.rb:30:in `instance_exec'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.6/lib/rails/initia
lizable.rb:30:in `run'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.6/lib/rails/initia
lizable.rb:55:in `block in run_initializers'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.6/lib/rails/initia
lizable.rb:54:in `each'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.6/lib/rails/initia
lizable.rb:54:in `run_initializers'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.6/lib/rails/applic
ation.rb:136:in `initialize!'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.6/lib/rails/railti
e/configurable.rb:30:in `method_missing'
from c:/rails_project/my_app/config/environment.rb:5:in `<top (required)
from c:/rails_project/my_app/config.ru:4:in `require'
from c:/rails_project/my_app/config.ru:4:in `block in <main>'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:
51:in `instance_eval'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:
51:in `initialize'
from c:/rails_project/my_app/config.ru:1:in `new'
from c:/rails_project/my_app/config.ru:1:in `<main>'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:
40:in `eval'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:
40:in `parse_file'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/server.rb:2
00:in `app'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.6/lib/rails/comman
ds/server.rb:46:in `app'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/server.rb:3
01:in `wrapped_app'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/server.rb:2
52:in `start'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.6/lib/rails/comman
ds/server.rb:70:in `start'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.6/lib/rails/comman
ds.rb:55:in `block in <top (required)>'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.6/lib/rails/comman
ds.rb:50:in `tap'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.6/lib/rails/comman
ds.rb:50:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
我正在使用Ruby 1.9.3p194(2012-04-20)[i386-mingw32]。
有什么想法吗?
答案 0 :(得分:4)
根据第5章中的调试日志和Rails教程,我了解到你试图复制并粘贴路径文件:
SampleApp::Application.routes.draw do
get "static_pages/home"
.......
end
SampleApp
此处代表应用程序的名称,我认为它应该是您的目录名称MyApp
。
您的路线文件应为:
MyApp::Application.routes.draw do
get "static_pages/home"
.......
end
这只是第一次猜测。