ruby-on-rails - Rails Byebug 没有停止应用程序

标签 ruby-on-rails ruby byebug

我想使用 byebug 来调试我的应用程序,但尽管我已经将 byebug 放入我的代码中,但该应用程序从未停止。这是我的 Gemfile。

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

  gem 'byebug', '~> 5.0.0'

  # Access an IRB console on exception pages or by using <%= console %> in views
  gem 'web-console', '~> 2.0'

end

我将 byebug 放入我的 Controller 之一。

def edit
  byebug
  present Ingredient::Update
end

我已经在我的 development.rb 中提出了我所有的本地请求。我已经重启服务器几次了。

config.consider_all_requests_local       = true

这是堆栈跟踪示例,byebug 仅打印第一条跟踪,然后应用继续执行下一行。

web_1 | [43, 52] in /recipe/app/controllers/ingredients_controller.rb
web_1 |    43:   def update
web_1 |    44:     run Ingredient::Update do |op|
web_1 |    45:       return redirect_to op.model
web_1 |    46:     end
web_1 |    47:     byebug
web_1 | => 48:     render action: :edit
web_1 |    49:   end
web_1 |    50:
web_1 |    51:   # DELETE /ingredients/1
web_1 |    52:   # DELETE /ingredients/1.json
web_1 | (byebug)   Rendered ingredients/edit.haml within layouts/application (264.1ms)
web_1 |   Rendered layouts/_navigation.haml (45.0ms)
web_1 | Completed 200 OK in 2827ms (Views: 2764.0ms | ActiveRecord: 3.9ms)
web_1 |
web_1 |
web_1 | Started GET "/assets/application.self-1ca8529ef221ef9dba25e835f258c4e62f2f49bce400273a67e63d7d73be28ba.css?body=1" for 192.168.59.3 at 2015-07-28 06:46:00 +0000

有什么想法吗? 更新 我在我的 Rails 应用程序中使用 docker-compose 和 docker。

最佳答案

docker-composebyebug 结合使用时,需要添加它以使其正常工作。发现于 this blog post

将此添加到 docker-compose.yml

web:
  ...
  stdin_open: true
  tty: true

然后在 deamonized 模式下运行 docker-compose 并使用 docker 附加到 web 容器:

docker-compose up -d
docker attach myappname_web_1

关于ruby-on-rails - Rails Byebug 没有停止应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31669226/

相关文章:

ruby-on-rails - 为什么 capistrano multiconfig 不工作?

ruby-on-rails - 使用 Faraday 和 Omniauth 进行 Rails 集成测试

ruby-on-rails - 为什么 byebug/pry 不会在 Rspec ActionMailer 的断点处停止?

ruby-on-rails - rails/Postgres : Column must appear in group by clause

ruby-on-rails - 可以在 Ruby on Rails 中只注释一个模型吗?

ruby-on-rails - Rails 默认的 CSRF 保护不安全吗?

ruby 正则表达式,解析 html

ruby-on-rails - 看起来 Bundler 找不到 gem 。也许您没有安装该应用程序所需的所有 gem

ruby-on-rails - 通过 docker-compose 使用远程 byebug 实例