当我尝试在带有 byebug 的 rails 中使用调试器时遇到问题...我安装了 byebug gem 没有任何问题...在 gemfile 中:
group :development, :test do
gem 'sqlite3'
gem 'byebug'
end
将调试器放在我的控制器中:
class ArticlesController < ApplicationController
before_action :set_article, only: [:edit, :update, :show, :destroy]
def new
@article = Article.new
end
def create
debugger
@article = Article.new(article_params)
# @article.user = User.first
if @article.save
flash[:success] = "Article was successfully created"
redirect_to article_path(@article)
else
render 'new'
end
end
def show
end
def index
@articles = Article.all
end
def edit
end
def update
if @article.update(article_params)
flash[:success] = "Article was successfully updated"
redirect_to article_path(@article)
else
render 'edit'
end
end
def destroy
@article.destroy
flash[:danger] = "Article was successfully 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
(我在windwos 7中使用gitbash)问题是当我尝试调用article_params时我只得到一个空行很长时间没有响应我试图重新启动我的服务器并再次尝试调试但同样的问题......这是一个问题的图像
这是来自 git bash 的代码(在图像中相同):
5: @article = Article.new
6: end
7:
8: def create
9: debugger
=> 10: @article = Article.new(article_params)
11: # @article.user = User.first
12: if @article.save
13: flash[:success] = "Article was successfully created"
14: redirect_to article_path(@article)
(byebug) article_params
-(here goes the blank line)
任何人都可以帮忙吗?