我正在尝试安装RSpec来对我没写的应用程序进行一些测试。我放了
gem“rspec-rails”,“〜> 2.8”
在我的gemfile中运行bundle install。这很好。直到我跑
rails生成rspec:install
我收到此错误:
/Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.20/lib/active_support/whiny_nil.rb:48:in
method_missing': undefined method
to_sym'代表nil:NilClass (NoMethodError)来自 /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.0.20/lib/action_dispatch/routing/mapper.rb:1309:in 来自action_path' from /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.0.20/lib/action_dispatch/routing/mapper.rb:1304:in
path_for_action' /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.0.20/lib/action_dispatch/routing/mapper.rb:1159:inmatch' from /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.0.20/lib/action_dispatch/routing/mapper.rb:1358:in
匹配来自 /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.0.20/lib/action_dispatch/routing/mapper.rb:394:inmap_method' from /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.0.20/lib/action_dispatch/routing/mapper.rb:323:in
来自 /Users/anthonyto/ActiveNetwork/active-trainer/config/routes.rb:447:in 来自控制器的block (4 levels) in <top (required)>' from /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.0.20/lib/action_dispatch/routing/mapper.rb:565:in
阻止 /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.0.20/lib/action_dispatch/routing/mapper.rb:546:in 来自scope' from /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.0.20/lib/action_dispatch/routing/mapper.rb:565:in
控制器' /Users/anthonyto/ActiveNetwork/active-trainer/config/routes.rb:446:in 名称空间中的block (3 levels) in <top (required)>' from /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.0.20/lib/action_dispatch/routing/mapper.rb:624:in
阻止来自 /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.0.20/lib/action_dispatch/routing/mapper.rb:546:inscope' from /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.0.20/lib/action_dispatch/routing/mapper.rb:624:in
命名空间来自 /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.0.20/lib/action_dispatch/routing/mapper.rb:1119:in {来自namespace' from /Users/anthonyto/ActiveNetwork/active-trainer/config/routes.rb:406:in
阻止(2级) /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.0.20/lib/action_dispatch/routing/mapper.rb:624:inblock in namespace' from /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.0.20/lib/action_dispatch/routing/mapper.rb:546:in
范围'来自 /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.0.20/lib/action_dispatch/routing/mapper.rb:624:innamespace' from /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.0.20/lib/action_dispatch/routing/mapper.rb:1119:in
命名空间来自 /Users/anthonyto/ActiveNetwork/active-trainer/config/routes.rb:405:in 来自block in <top (required)>' from /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.0.20/lib/action_dispatch/routing/route_set.rb:239:in
instance_exec' /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.0.20/lib/action_dispatch/routing/route_set.rb:239:in 来自draw' from /Users/anthonyto/ActiveNetwork/active-trainer/config/routes.rb:1:in
' /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:236:inload' from /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:236:in
阻止加载'来自 /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:225:in 来自block in load_dependency' from /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:597:in
new_constants_in' /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:225:in 来自load_dependency' from /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:236:in
加载' /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.20/lib/rails/application.rb:127:in 每个block in reload_routes!' from /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.20/lib/rails/application.rb:127:in
来自 /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.20/lib/rails/application.rb:127:in 来自routes_reloader的reload_routes!' from /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.20/lib/rails/application.rb:120:in
阻止 /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.20/lib/active_support/file_update_checker.rb:32:in 来自call' from /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.20/lib/active_support/file_update_checker.rb:32:in
execute_if_updated' /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.20/lib/rails/application/finisher.rb:51:inblock (2 levels) in <module:Finisher>' from /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.20/lib/rails/application/finisher.rb:52:in
来电 /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.20/lib/rails/application/finisher.rb:52:in 来自block in <module:Finisher>' from /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.20/lib/rails/initializable.rb:25:in
instance_exec' /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.20/lib/rails/initializable.rb:25:in 来自run_initializers的run' from /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.20/lib/rails/initializable.rb:50:in
阻止 /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.20/lib/rails/initializable.rb:49:in 来自each' from /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.20/lib/rails/initializable.rb:49:in
run_initializers' /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.20/lib/rails/application.rb:134:ininitialize!' from /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.20/lib/rails/application.rb:77:in
method_missing'来自 /Users/anthonyto/ActiveNetwork/active-trainer/config/environment.rb:5:in<top (required)>' from /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:242:in
需要'来自 /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:242:in 来自{load = dependency'的block in require' from /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:225:in
阻止 /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:597:in 来自new_constants_in' from /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:225:in
load_dependency' /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:242:inrequire' from /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.20/lib/rails/application.rb:103:in
require_environment!”从 /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.20/lib/rails/commands.rb:16:in<top (required)>' from script/rails:7:in
需要'来自 script / rails:7:in''
我正在运行ruby版本1.9.3和rails 3.0.20版本。我可以提供任何其他信息,非常感谢任何帮助。谢谢大家!
编辑:当我尝试启动我的rails服务器时,我得到同样的错误。似乎我的应用程序存在更深层次的问题。我以前当然没有这个问题,也不会想到我做过的任何事情会导致它。
答案 0 :(得分:0)
FIX:所以我弄明白发生了什么,我会留在这里为遇到这个恼人错误的其他人。事实证明我是一个白痴,并在routes.rb文件中留下了一些错误的代码,如下所示:
controller :calendar do get #write some routes here end
评论说,一切正常。