1

我和这个问题有同样的问题。我byebug在这个类中使用:

class BasesController < ApplicationController
  before_action :set_available_bases, only: [:index]

  def index
  end

  private
  def set_available_bases
    byebug
    @bases = Base.all
  end

end

我得到

NameError (undefined local variable or method `byebug' for #<BasesController:0x5952e10>):

如果我require 'byebug'按照第一个答案中的建议添加,我会得到cannot load such file -- byebug. 默认情况下,byebug 已经在我的 Gemfile 中使用 Rails 5

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platform: :mri
end

我已经跑了gem install byebugbundler install。我有 ruby​​ 2.3.3p222,rails 5.0.1,在 Windows 10 上运行。

知道如何解决这个问题吗?

4

0 回答 0