我想在Rails中调试一个项目。但是,我经常在浏览器中得到这个错误:undefined local variable或method byebug'for#“<”ArticlesController:0x9430c68>。 的文章控制器的代码是:Rails调试错误
group :development, :test do
gem 'sqlite3'
# Call 'byebug' anywhere in the code to stop execution and get a debugger
console
gem 'byebug', platform: :mri
end
我:
class ArticlesController < ApplicationController
before_action :set_article,only: [:edit,:update,:show,:destroy]
def index
@articles = Article.all
end
def new
@article = Article.new
end
def create
byebug
@article = Article.new(article_params)
#@article.user = User.first
if @article.save
flash[:success] = "Article was succesfully created."
redirect_to article_path(@article)
else
render 'new'
end
end
def edit
end
def update
if @article.update(article_params)
flash[:success] = "Article was succesfully updated."
redirect_to article_path(@article)
else
render 'edit'
end
end
def show
end
def destroy
@article.destroy
flash[:danger]="Article was succesfully deleted."
redirect_to articles_path
end
private
def set_article
@article = Article.find(params[:id])
end
def article_params
params.require(:article).permit(:title,:description)
end
end
逻辑上byebug命令,在“创建” action.The宝石“byebug”安装在Gemfile中出现错误在Rails 5中工作,而我的IDE是Atom.I已经搜索并尝试了多个答案,其中没有任何一个能够工作,所以我已经将所有内容都回复到了原来的样子。感谢您花时间解决这个问题,这意味着很多!
你在MRI上运行吗,还是像JRuby这样的其他平台? – Unixmonkey
你使用的是Windows吗? – Belder
我正在使用Windows 8.1。 – ds998