2

老实说,我很迷茫。每次我尝试运行任何 rails commandsie, rails g controller home时,命令行都会向我抛出这个错误,我不知道发生了什么。我已经卸载并重新安装spring了,我也用谷歌搜索了。

有人帮忙吗?

Johnny@Johnnys-MacBook-Pro original_skillup (feature/s3_uploader) $ rails g controller spring
/Users/Johnny/.rvm/gems/ruby-2.2.1/gems/spring-1.3.6/lib/spring/application.rb:102:in `block in preload': undefined method `[]' for nil:NilClass (NoMethodError)
  from /Users/Johnny/.rvm/gems/ruby-2.2.1/gems/spring-1.3.6/lib/spring/application.rb:102:in `map'
  from /Users/Johnny/.rvm/gems/ruby-2.2.1/gems/spring-1.3.6/lib/spring/application.rb:102:in `rescue in preload'
  from /Users/Johnny/.rvm/gems/ruby-2.2.1/gems/spring-1.3.6/lib/spring/application.rb:115:in `preload'
  from /Users/Johnny/.rvm/gems/ruby-2.2.1/gems/spring-1.3.6/lib/spring/application.rb:143:in `serve'
  from /Users/Johnny/.rvm/gems/ruby-2.2.1/gems/spring-1.3.6/lib/spring/application.rb:131:in `block in run'
  from /Users/Johnny/.rvm/gems/ruby-2.2.1/gems/spring-1.3.6/lib/spring/application.rb:125:in `loop'
  from /Users/Johnny/.rvm/gems/ruby-2.2.1/gems/spring-1.3.6/lib/spring/application.rb:125:in `run'
  from /Users/Johnny/.rvm/gems/ruby-2.2.1/gems/spring-1.3.6/lib/spring/application/boot.rb:18:in `<top (required)>'
  from /Users/Johnny/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
  from /Users/Johnny/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
  from -e:1:in `<main>'

谢谢!

4

3 回答 3

2

我认为您安装了 Spring gem 并且控制器的名称有冲突。

https://github.com/rails/spring

尝试更改控制器的名称。希望它有效。干杯!

于 2015-06-11T01:40:08.100 回答
0

对于上一个答案,您可以拥有一个名为 home 的控制器(没有命名问题)。看起来您使用的 spring gem 的版本确实存在问题。您是否尝试过运行“捆绑安装”?我在 Github 上查看了 spring gem,看起来该 gem 没有任何当前问题。您可以移除 spring gem 并查看问题是否仍然存在,如果是,那么您知道问题存在更深层次。

于 2015-06-11T01:46:28.743 回答
0

那是 spring gem 中的异常回溯问题。

https://github.com/rails/spring/pull/459

将 spring 更新到 1.6.1

于 2015-12-23T01:09:06.970 回答