一个很好用的工具,那就是pry
gem install pry
然后再程序中加入binding.pry, 当系统执行到这里后,就会自行停下来。
2: attr_accessible :name, :content, :published_at
3: has_many :comments
4:
5: def word_count
6: words = content.scan(/\w+/)
=> 7: binding.pry
8: words.size
9: end
10: end
然后就可以在对话框内输入任何参数, 比如输入words 就可以知道words的值
当然还有其他命令 比如 next, continue.
具体的请看源代码
https://github.com/nixme/pry-nav