我想调试ROR而不需要为控制器中的每个相关对象设置检查方法以及模型。我们有更好的方法在Java(使用eclipse运行时调试器) 。我知道我可以使用Rails.logger
并使用rails Console(irb`)。我甚至知道在erb / rb文件中调试/检查元素。还有一种更好,快速和可靠的方法来调试Rails应用程序 。
There is much better, see this railscats .
It presents two great gems, especially Better Errors
Otherwise, you could use pry with rails, see this railscast .
你也可以使用pry-rails
, pry-debugger
然后在你的代码中使用binding.pry
方法然后在使用你的应用程序时你可以在rails服务器中使用Rails控制台
Add this lines to your application's Gemfile
group :development do
gem 'ruby-debug19'
end
then run cammand
bundle install
add debugger
within your controller or model method, stop the rails server and restart again. Whenever rails found word debugger
it stops control at that point. You can easily debug your value or object. Hope this will helps you.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.