【问题标题】:is it possible to start the Rails console from within your code?是否可以从您的代码中启动 Rails 控制台?
【发布时间】:2009-04-30 19:13:45
【问题描述】:

我知道 ruby​​ gem "ruby-debug" 允许您在代码中放置 debugger 调用。使用它,您的代码中可能会有断点。

我在一些测试中使用了 script/console,我想知道是否可以从我的代码中调用它。

谢谢!

编辑:

这里是一些示例 ruby​​ 代码


require "ruby-debug"

[1,2,3,4,5].each do |item|
   if item == 2
      # this starts a irb-like shell from which you can step through your code
      debugger 
   end
end

我想实现同样的目标,但使用 rails 控制台。

【问题讨论】:

    标签: ruby-on-rails debugging console


    【解决方案1】:

    在调试时,您可以输入irb 来打开控制台。除此之外,我不确定我是否理解您的意思......

    【讨论】:

      【解决方案2】:

      我认为唯一的方法是在代码中添加 debugger 语句。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2015-06-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2010-11-25
        • 2014-08-08
        • 2014-08-06
        相关资源
        最近更新 更多