开发者

Ruby on Rails Debug Question

Hello guys I have this video tutorial on Ruby on Rails and I see that the guy has a bottom script debug, in the browser window. The problem is, I have only one part of that video tutorial (that part is free) and he says nothing about that debug. Maybe you guys can figur开发者_JAVA技巧e it out.

Here's a screenshot with it: http://i55.tinypic.com/3537drp.png

How can I achieve that? Thanks.


In the view, doing something like

<%= debug params %> 

will achieve what you have shown. Using the debug helper you can basically get a yaml dump of any variable that's available to the view, it will also "prettyfy" the dump by formatting it in a <pre> block and using a different background color. From the looks of what he has, he might have added that to the bottom of a layout (might be in app/views/layouts/application.html.erb). That will give you that dump in any of your pages.


The Rails Footnotes gem is very easy to configure and includes information like:

  • variable assignments
  • params action / controller
  • route information
  • SQL statements & execution times

Check it out:

https://github.com/josevalim/rails-footnotes


Looks like he's just rendering params.to_yaml onto the page.


you should maybe consider running rails with the --debugger flag as exemplified in this guide: http://guides.rubyonrails.org/debugging_rails_applications.html


for debugging the view you can simply <% debugger %> in your view page wherever your want to see the dataflow and load that view again and on the console you can run each line of view and see the data flow.. and make sure you have debugger gem in your gem file.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜