简体   繁体   English

在rails 3中调试

[英]Debugging in rails 3

我想调试ROR而不需要为控制器中的每个相关对象设置检查方法以及模型。我们有更好的方法在Java(使用eclipse运行时调试器) 。我知道我可以使用Rails.logger并使用rails Console(irb`)。我甚至知道在erb / rb文件中调试/检查元素。还有一种更好,快速和可靠的方法来调试Rails应用程序

There is much better, see this railscats . 有更好的,看到这个railscats

It presents two great gems, especially Better Errors 它呈现了两个伟大的宝石,尤其是更好的错误

Otherwise, you could use pry with rails, see this railscast . 否则,你可以使用护栏带,看到这个railscast

你也可以使用pry-railspry-debugger然后在你的代码中使用binding.pry方法然后在使用你的应用程序时你可以在rails服务器中使用Rails控制台

Add this lines to your application's Gemfile 将此行添加到应用程序的Gemfile中

group :development do
  gem 'ruby-debug19'
end

then run cammand 然后运行cammand

 bundle install

add debugger within your controller or model method, stop the rails server and restart again. 在控制器或模型方法中添加debugger ,停止rails服务器并重新启动。 Whenever rails found word debugger it stops control at that point. 每当rails找到word debugger它就会在那时停止控制。 You can easily debug your value or object. 您可以轻松调试您的价值或对象。 Hope this will helps you. 希望这会对你有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM