Rails console error: undefined method `each' for nil:NilClass (NoMethodError)
Rails console error: undefined method `each' for nil:NilClass (NoMethodError)
在我的 Rails 应用程序的根目录中对 运行 rails console
的任何尝试都会产生以下错误:
undefined method `each' for nil:NilClass (NoMethodError)
完整堆栈跟踪:
/Users/gnerkus/.rvm/gems/ruby-2.2.3@rails-experiments/gems/railties-5.0.0.beta1.1/lib/rails/railtie.rb:245:in `each_registered_block': undefined method `each' for nil:NilClass (NoMethodError)
from /Users/gnerkus/.rvm/gems/ruby-2.2.3@rails-experiments/gems/railties-5.0.0.beta1.1/lib/rails/railtie.rb:224:in `run_console_blocks'
from /Users/gnerkus/.rvm/gems/ruby-2.2.3@rails-experiments/gems/railties-5.0.0.beta1.1/lib/rails/application.rb:461:in `block in run_console_blocks'
from /Users/gnerkus/.rvm/gems/ruby-2.2.3@rails-experiments/gems/railties-5.0.0.beta1.1/lib/rails/engine/railties.rb:13:in `each'
from /Users/gnerkus/.rvm/gems/ruby-2.2.3@rails-experiments/gems/railties-5.0.0.beta1.1/lib/rails/engine/railties.rb:13:in `each'
from /Users/gnerkus/.rvm/gems/ruby-2.2.3@rails-experiments/gems/railties-5.0.0.beta1.1/lib/rails/application.rb:461:in `run_console_blocks'
from /Users/gnerkus/.rvm/gems/ruby-2.2.3@rails-experiments/gems/railties-5.0.0.beta1.1/lib/rails/engine.rb:442:in `load_console'
from /Users/gnerkus/.rvm/gems/ruby-2.2.3@rails-experiments/gems/railties-5.0.0.beta1.1/lib/rails/commands/console.rb:34:in `initialize'
from /Users/gnerkus/.rvm/gems/ruby-2.2.3@rails-experiments/gems/railties-5.0.0.beta1.1/lib/rails/commands/console_helper.rb:9:in `new'
from /Users/gnerkus/.rvm/gems/ruby-2.2.3@rails-experiments/gems/railties-5.0.0.beta1.1/lib/rails/commands/console_helper.rb:9:in `start'
from /Users/gnerkus/.rvm/gems/ruby-2.2.3@rails-experiments/gems/railties-5.0.0.beta1.1/lib/rails/commands/commands_tasks.rb:78:in `console'
from /Users/gnerkus/.rvm/gems/ruby-2.2.3@rails-experiments/gems/railties-5.0.0.beta1.1/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
from /Users/gnerkus/.rvm/gems/ruby-2.2.3@rails-experiments/gems/railties-5.0.0.beta1.1/lib/rails/command.rb:20:in `run'
from /Users/gnerkus/.rvm/gems/ruby-2.2.3@rails-experiments/gems/railties-5.0.0.beta1.1/lib/rails/commands.rb:19:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
我已将错误追踪到 Rails 库中的 railtie.rb
文件中的这个块:
def each_registered_block(type, &block)
klass = self.class
while klass.respond_to?(type)
# The ':console' type doesn't seem to exist
klass.public_send(type).each(&block)
klass = klass.superclass
end
end
这又来自这个区块:
def run_console_blocks(app) #:nodoc:
each_registered_block(:console) { |block| block.call(app) }
end
我卸载了 spring
gem 并安装了 rubocop
gem。否则,我的 Gemfile
包含默认的 gems.
我的 Ruby 版本是 2.2.3
,高于为 Rails 5.
推荐的 2.2.2
版本
Ruby版本:2.2.3p173
Rails版本:5.0.0.beta1.1
RVM 版本: 1.26.11
错误是由此处引用的 web-console
gem 引起的:Error when running rails console。报告时 web-console
的版本为 3.1.0
。 3.0.0
版本的 web-console
似乎在执行 rails console
时没有产生任何错误。
您需要确保您的 web-console
版本为 3.1.1
或更高版本,因为此问题已在 3.1.1
版本中修复。
您需要安装springgem
gem install spring --pre
gem install spring
为我工作。
我的问题是:
/usr/local/bin/NMONMerge.rb:209:in `block in <main>': undefined method `each' for nil:NilClass (NoMethodError)
from /usr/local/bin/NMONMerge.rb:191:in `each'
from /usr/local/bin/NMONMerge.rb:191:in `<main>'
在我的 Rails 应用程序的根目录中对 运行 rails console
的任何尝试都会产生以下错误:
undefined method `each' for nil:NilClass (NoMethodError)
完整堆栈跟踪:
/Users/gnerkus/.rvm/gems/ruby-2.2.3@rails-experiments/gems/railties-5.0.0.beta1.1/lib/rails/railtie.rb:245:in `each_registered_block': undefined method `each' for nil:NilClass (NoMethodError)
from /Users/gnerkus/.rvm/gems/ruby-2.2.3@rails-experiments/gems/railties-5.0.0.beta1.1/lib/rails/railtie.rb:224:in `run_console_blocks'
from /Users/gnerkus/.rvm/gems/ruby-2.2.3@rails-experiments/gems/railties-5.0.0.beta1.1/lib/rails/application.rb:461:in `block in run_console_blocks'
from /Users/gnerkus/.rvm/gems/ruby-2.2.3@rails-experiments/gems/railties-5.0.0.beta1.1/lib/rails/engine/railties.rb:13:in `each'
from /Users/gnerkus/.rvm/gems/ruby-2.2.3@rails-experiments/gems/railties-5.0.0.beta1.1/lib/rails/engine/railties.rb:13:in `each'
from /Users/gnerkus/.rvm/gems/ruby-2.2.3@rails-experiments/gems/railties-5.0.0.beta1.1/lib/rails/application.rb:461:in `run_console_blocks'
from /Users/gnerkus/.rvm/gems/ruby-2.2.3@rails-experiments/gems/railties-5.0.0.beta1.1/lib/rails/engine.rb:442:in `load_console'
from /Users/gnerkus/.rvm/gems/ruby-2.2.3@rails-experiments/gems/railties-5.0.0.beta1.1/lib/rails/commands/console.rb:34:in `initialize'
from /Users/gnerkus/.rvm/gems/ruby-2.2.3@rails-experiments/gems/railties-5.0.0.beta1.1/lib/rails/commands/console_helper.rb:9:in `new'
from /Users/gnerkus/.rvm/gems/ruby-2.2.3@rails-experiments/gems/railties-5.0.0.beta1.1/lib/rails/commands/console_helper.rb:9:in `start'
from /Users/gnerkus/.rvm/gems/ruby-2.2.3@rails-experiments/gems/railties-5.0.0.beta1.1/lib/rails/commands/commands_tasks.rb:78:in `console'
from /Users/gnerkus/.rvm/gems/ruby-2.2.3@rails-experiments/gems/railties-5.0.0.beta1.1/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
from /Users/gnerkus/.rvm/gems/ruby-2.2.3@rails-experiments/gems/railties-5.0.0.beta1.1/lib/rails/command.rb:20:in `run'
from /Users/gnerkus/.rvm/gems/ruby-2.2.3@rails-experiments/gems/railties-5.0.0.beta1.1/lib/rails/commands.rb:19:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
我已将错误追踪到 Rails 库中的 railtie.rb
文件中的这个块:
def each_registered_block(type, &block)
klass = self.class
while klass.respond_to?(type)
# The ':console' type doesn't seem to exist
klass.public_send(type).each(&block)
klass = klass.superclass
end
end
这又来自这个区块:
def run_console_blocks(app) #:nodoc:
each_registered_block(:console) { |block| block.call(app) }
end
我卸载了 spring
gem 并安装了 rubocop
gem。否则,我的 Gemfile
包含默认的 gems.
我的 Ruby 版本是 2.2.3
,高于为 Rails 5.
2.2.2
版本
Ruby版本:2.2.3p173
Rails版本:5.0.0.beta1.1
RVM 版本: 1.26.11
错误是由此处引用的 web-console
gem 引起的:Error when running rails console。报告时 web-console
的版本为 3.1.0
。 3.0.0
版本的 web-console
似乎在执行 rails console
时没有产生任何错误。
您需要确保您的 web-console
版本为 3.1.1
或更高版本,因为此问题已在 3.1.1
版本中修复。
您需要安装springgem
gem install spring --pre
gem install spring
为我工作。
我的问题是:
/usr/local/bin/NMONMerge.rb:209:in `block in <main>': undefined method `each' for nil:NilClass (NoMethodError)
from /usr/local/bin/NMONMerge.rb:191:in `each'
from /usr/local/bin/NMONMerge.rb:191:in `<main>'