<divclass="para"><p>Displaying an instance variable, or any other object or method, in yaml format can be achieved this way:</p></div>

<divclass="listingblock">

@@ -373,10 +370,7 @@ <h3 id="_to_yaml">1.2. to_yaml</h3>

<divclass="para"><p>The <tt>to_yaml</tt> method converts the method to YAML format leaving it more readable, and then the <tt>simple_format</tt> helper is used to render each line as in the console. This is how <tt>debug</tt> method does its magic.</p></div>

<divclass="para"><p>As a result of this, you will have something like this in your view:</p></div>

<divclass="listingblock">

-<divclass="content"><!-- Generator: GNU source-highlight 2.9

-by Lorenzo Bettini

-http://www.lorenzobettini.it

-http://www.gnu.org/software/src-highlite -->

+<divclass="content">

<pre><tt>--- !ruby/object:Post

attributes:

updated_at: 2008-09-05 22:55:47

@@ -387,8 +381,8 @@ <h3 id="_to_yaml">1.2. to_yaml</h3>

created_at: 2008-09-05 22:55:47

attributes_cache: {}

-Title: Rails debugging guide

-</tt></pre></div></div>

+Title: Rails debugging guide</tt></pre>

+</div></div>

<h3id="_inspect">1.3. inspect</h3>

<divclass="para"><p>Another useful method for displaying object values is <tt>inspect</tt>, especially when working with arrays or hashes. This will print the object value as a string. For example:</p></div>

<divclass="listingblock">

@@ -404,14 +398,11 @@ <h3 id="_inspect">1.3. inspect</h3>

</tt></pre></div></div>

<divclass="para"><p>Will be rendered as follows:</p></div>

<divclass="listingblock">

-<divclass="content"><!-- Generator: GNU source-highlight 2.9

-by Lorenzo Bettini

-http://www.lorenzobettini.it

-http://www.gnu.org/software/src-highlite -->

+<divclass="content">

<pre><tt>[1, 2, 3, 4, 5]

-Title: Rails debugging guide

-</tt></pre></div></div>

+Title: Rails debugging guide</tt></pre>

+</div></div>

<h3id="_debugging_javascript">1.4. Debugging Javascript</h3>

<divclass="para"><p>Rails has built-in support to debug RJS, to active it, set <tt>ActionView::Base.debug_rjs</tt> to <em>true</em>, this will specify whether RJS responses should be wrapped in a try/catch block that alert()s the caught exception (and then re-raises it).</p></div>

<divclass="para"><p>To enable it, add the following in the <tt>Rails::Initializer do |config|</tt> block inside <tt>environment.rb</tt>:</p></div>

<divclass="para"><p>Adding extra logging like this makes it easy to search for unexpected or unusual behavior in your logs. If you add extra logging, be sure to make sensible use of log levels, to avoid filling your production logs with useless trivia.</p></div>

</div>

<h2id="_debugging_with_ruby_debug">3. Debugging with ruby-debug</h2>

@@ -581,12 +569,9 @@ <h3 id="_setup">3.1. Setup</h3>

</tt></pre></div></div>

<divclass="para"><p>If you see the message in the console or logs:</p></div>

<divclass="listingblock">

-<divclass="content"><!-- Generator: GNU source-highlight 2.9

-by Lorenzo Bettini

-http://www.lorenzobettini.it

-http://www.gnu.org/software/src-highlite -->

-<pre><tt>***** Debugger requested, but was not available: Start server with --debugger to enable *****

-</tt></pre></div></div>

+<divclass="content">

+<pre><tt>***** Debugger requested, but was not available: Start server with --debugger to enable *****</tt></pre>

+</div></div>

<divclass="para"><p>Make sure you have started your web server with the option <tt>&#8212;debugger</tt>:</p></div>

<divclass="listingblock">

<divclass="content"><!-- Generator: GNU source-highlight 2.9

@@ -1010,14 +995,11 @@ <h3 id="_settings">3.12. Settings</h3>

</div>

<divclass="para"><p>Here's a good start for an <tt>.rdebugrc</tt>:</p></div>

<divclass="listingblock">

-<divclass="content"><!-- Generator: GNU source-highlight 2.9

-by Lorenzo Bettini

-http://www.lorenzobettini.it

-http://www.gnu.org/software/src-highlite -->

+<divclass="content">

<pre><tt>set autolist

set forcestep

-set listsize 25

-</tt></pre></div></div>

+set listsize 25</tt></pre>

+</div></div>

</div>

<h2id="_debugging_memory_leaks">4. Debugging Memory Leaks</h2>

<divclass="sectionbody">

@@ -1046,20 +1028,14 @@ <h3 id="_bleakhouse">4.1. BleakHouse</h3>

</div></div>

<divclass="para"><p>Make sure to run a couple hundred requests to get better data samples, then press <tt>CTRL-C</tt>. The server will stop and Bleak House will produce a dumpfile in <tt>/tmp</tt>:</p></div>

<divclass="para"><p>This way you can find where your application is leaking memory and fix it.</p></div>

<divclass="para"><p>If <ahref="http://github.com/fauna/bleak_house/tree/master">BleakHouse</a> doesn't report any heap growth but you still have memory growth, you might have a broken C extension, or real leak in the interpreter. In that case, try using Valgrind to investigate further.</p></div>

<divclass="para"><p>As alternatives to calling <tt>Client.first</tt>, <tt>Client.last</tt>, and <tt>Client.all</tt>, you can use the class methods <tt>Client.first</tt>, <tt>Client.last</tt>, and <tt>Client.all</tt> instead. <tt>Client.first</tt>, <tt>Client.last</tt> and <tt>Client.all</tt> just call their longer counterparts: <tt>Client.find(:first)</tt>, <tt>Client.find(:last)</tt> and <tt>Client.find(:all)</tt> respectively.</p></div>

<divclass="para"><p>Be aware that <tt>Client.first</tt>/<tt>Client.find(:first)</tt> and <tt>Client.last</tt>/<tt>Client.find(:last)</tt> will both return a single object, where as <tt>Client.all</tt>/<tt>Client.find(:all)</tt> will return an array of Client objects, just as passing in an array of ids to find will do also.</p></div>