使用Ruby 1.9.3和Rails 3.2.13启动rails server 3时出错

时间:2013-05-06 00:23:47

标签: ruby-on-rails

我是一名新的Ruby on Rails开发人员,目前正在学习基础知识:
http://guides.rubyonrails.org/getting_started.html

当我尝试启动Rails服务器时遇到问题:     $ rails server

我收到如下的冗长错误消息:

=> Booting WEBrick
=> Rails 3.2.13 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/Users/tyhomemac/Programming/rails_projects/blog/config/routes.rb:4:in `block (2 levels) in <top (required)>': undefined method `resoures' for #<ActionDispatch::Routing::Mapper:0x007ffee3b45188> (NoMethodError)
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/actionpack-3.2.13/lib/action_dispatch/routing/mapper.rb:1124:in `block in resources'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/actionpack-3.2.13/lib/action_dispatch/routing/mapper.rb:1406:in `block (2 levels) in resource_scope'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/actionpack-3.2.13/lib/action_dispatch/routing/mapper.rb:618:in `scope'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/actionpack-3.2.13/lib/action_dispatch/routing/mapper.rb:1405:in `block in resource_scope'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/actionpack-3.2.13/lib/action_dispatch/routing/mapper.rb:1397:in `with_scope_level'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/actionpack-3.2.13/lib/action_dispatch/routing/mapper.rb:1404:in `resource_scope'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/actionpack-3.2.13/lib/action_dispatch/routing/mapper.rb:1123:in `resources'
    from /Users/tyhomemac/Programming/rails_projects/blog/config/routes.rb:3:in `block in <top (required)>'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:289:in `instance_exec'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:289:in `eval_block'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:267:in `draw'
    from /Users/tyhomemac/Programming/rails_projects/blog/config/routes.rb:1:in `<top (required)>'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:245:in `load'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:245:in `block in load'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:236:in `load_dependency'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:245:in `load'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/application/routes_reloader.rb:40:in `block in load_paths'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/application/routes_reloader.rb:40:in `each'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/application/routes_reloader.rb:40:in `load_paths'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/application/routes_reloader.rb:16:in `reload!'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/application/routes_reloader.rb:26:in `block in updater'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.13/lib/active_support/file_update_checker.rb:78:in `call'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.13/lib/active_support/file_update_checker.rb:78:in `execute'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/application/routes_reloader.rb:27:in `updater'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/application/routes_reloader.rb:9:in `rescue in execute_if_updated'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/application/routes_reloader.rb:7:in `execute_if_updated'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/application/finisher.rb:66:in `block in <module:Finisher>'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `instance_exec'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `run'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/initializable.rb:55:in `block in run_initializers'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `each'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `run_initializers'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/application.rb:136:in `initialize!'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/railtie/configurable.rb:30:in `method_missing'
    from /Users/tyhomemac/Programming/rails_projects/blog/config/environment.rb:5:in `<top (required)>'
    from /Users/tyhomemac/Programming/rails_projects/blog/config.ru:3:in `require'
    from /Users/tyhomemac/Programming/rails_projects/blog/config.ru:3:in `block in <main>'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/rack-1.4.5/lib/rack/builder.rb:51:in `instance_eval'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/rack-1.4.5/lib/rack/builder.rb:51:in `initialize'
    from /Users/tyhomemac/Programming/rails_projects/blog/config.ru:in `new'
    from /Users/tyhomemac/Programming/rails_projects/blog/config.ru:in `<main>'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/rack-1.4.5/lib/rack/builder.rb:40:in `eval'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/rack-1.4.5/lib/rack/builder.rb:40:in `parse_file'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/rack-1.4.5/lib/rack/server.rb:200:in `app'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/commands/server.rb:46:in `app'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/rack-1.4.5/lib/rack/server.rb:304:in `wrapped_app'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/rack-1.4.5/lib/rack/server.rb:254:in `start'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/commands/server.rb:70:in `start'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/commands.rb:55:in `block in <top (required)>'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/commands.rb:50:in `tap'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/commands.rb:50:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

我在网上搜索并根据回复: Ruby 1.9.2 and Rails 3 cannot open rails console

我尝试了以下代码:

rvm pkg install readline
rvm remove 1.9.3
rvm install 1.9.3 --with-readline-dir=$rvm_path/usr

但是,这并没有解决错误消息,我继续遇到同样的问题。

我正在运行ruby 1.9.3p392 (2013-02-22 revision 39386) [x86_64-darwin12.3.0]Rails 3.2.13

如果我应该提供任何其他信息,请告诉我。

2 个答案:

答案 0 :(得分:3)

要么在config/routes.rb文件中拼错了资源声明,要么在生成器中使用了宝石。在所述文件中搜索resoures并将其替换为resources

这就是错误所指的:

undefined method 'resoures'

答案 1 :(得分:0)

存在拼写错误。检查&#34;资源&#34;

的拼写