【发布时间】:2016-06-15 12:31:58
【问题描述】:
当我尝试在带有 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 时我只得到一个空行很长时间没有响应我试图重新启动我的服务器并再次尝试调试但同样的问题....Here is an image for the problem
这是来自 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)
有人可以帮忙吗?
【问题讨论】:
-
能把控制器的全部代码放上来吗?
-
Milan Pudasini ..我更新了它,你可以看到我的控制器的整个代码..
-
删除调试器一次并把 byebug 放在那个地方
-
我建议不要使用 Windows 来开发 Rails 应用程序。 Ruby CLI、Rails CLI、Git CLI 和一般部署过程在基于 Linux 的终端/环境中要好得多。如果那是你唯一的 PC,我会用 VirtualBox 安装 Ubuntu 并改用它。
-
嗨@MilanPudasini 我通过迁移到 ubuntu 解决了这个问题,就像他们在上面告诉我的那样......无论如何,谢谢你;)
标签: ruby-on-rails debugging ruby-on-rails-4 rubygems byebug