<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>RealityForge.org: Rails Plugin to Help Debug Views</title>
    <link>/articles/2006/03/20/rails-plugin-to-help-debug-views</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>A little short for a storm trooper</description>
    <item>
      <title>Rails Plugin to Help Debug Views</title>
      <description>&lt;p&gt;The debug_view_helper plugin was developed to make it easy to add debug information into your views. It was derived from techniques described in &lt;a href="http://wiki.rubyonrails.com/rails/pages/HowtoDebugViews"&gt;HowtoDebugViews&lt;/a&gt;  and it makes it possible to expose the followng following debug data;&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;Request Parameters&lt;/li&gt;
		&lt;li&gt;Session Variables&lt;/li&gt;
		&lt;li&gt;Flash Variables&lt;/li&gt;
		&lt;li&gt;Assigned Template Variables&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;Typically you add code such as the following to the bottom of your layout that exposes the debug button in development mode.&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="punct"&gt;&amp;lt;%&lt;/span&gt; &lt;span class="keyword"&gt;if&lt;/span&gt; &lt;span class="constant"&gt;RAILS_ENV&lt;/span&gt; &lt;span class="punct"&gt;==&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;development&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt; &lt;span class="punct"&gt;%&amp;gt;&lt;/span&gt;&lt;span class="string"&gt;
&amp;lt;center&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="ident"&gt;button&lt;/span&gt; &lt;span class="ident"&gt;onclick&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;show_debug_popup(); return false;&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&amp;gt;&lt;/span&gt;
    &lt;span class="constant"&gt;Show&lt;/span&gt; &lt;span class="ident"&gt;debug&lt;/span&gt; &lt;span class="ident"&gt;popup&lt;/span&gt;
  &lt;span class="punct"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="regex"&gt;button&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span class="punct"&gt;/&lt;/span&gt;&lt;span class="ident"&gt;center&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="punct"&gt;&amp;lt;%=&lt;/span&gt;&lt;span class="string"&gt; debug_popup %&amp;gt;
&amp;lt;% end %&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;You can grab the plugin from subversion at;&lt;/p&gt;


	&lt;p&gt;&lt;a href="http://www.realityforge.org/svn/code/debug-view-helper/trunk/"&gt;http://www.realityforge.org/svn/code/debug-view-helper/trunk/&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;&lt;b&gt;Update:&lt;/b&gt; Added the ability to add inline debug information via the following. Suggestion by  John Dell.&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="punct"&gt;&amp;lt;%&lt;/span&gt; &lt;span class="keyword"&gt;if&lt;/span&gt; &lt;span class="constant"&gt;RAILS_ENV&lt;/span&gt; &lt;span class="punct"&gt;==&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;development&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt; &lt;span class="punct"&gt;%&amp;gt;&lt;/span&gt;&lt;span class="string"&gt;
&amp;lt;%= debug_inline %&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="punct"&gt;&amp;lt;%&lt;/span&gt; &lt;span class="keyword"&gt;end&lt;/span&gt; &lt;span class="punct"&gt;%&amp;gt;&lt;/span&gt;&lt;span class="string"&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description>
      <pubDate>Mon, 20 Mar 2006 14:02:00 +1100</pubDate>
      <guid isPermaLink="false">urn:uuid:3b08aded-4f0c-4955-9cdf-a39457c1a9aa</guid>
      <author>Peter Donald</author>
      <link>http://www.realityforge.org/articles/2006/03/20/rails-plugin-to-help-debug-views</link>
      <category>Rails</category>
      <category>rails</category>
      <category>debug</category>
      <trackback:ping>http://www.realityforge.org/articles/trackback/40</trackback:ping>
    </item>
    <item>
      <title>"Rails Plugin to Help Debug Views" by Jeremy Wohl</title>
      <description>&lt;p&gt;I couldn&amp;#8217;t get this working in Rails 1.1, w/o the following patch.  There&amp;#8217;s probably a better way to do it.&lt;/p&gt;


&lt;hr /&gt;x/view_debug_helper.rb      2006-03-31 13:34:38.000000000 -0800
&lt;ins&gt;+&lt;/ins&gt; view_debug_helper.rb        2006-03-31 13:35:22.000000000 -0800
&lt;code&gt;@ -44,7 +44,7 &lt;/code&gt;@
       end
     end


	&lt;p&gt;-    dump_vars(script,&amp;#8217;Session Variables:&amp;#8217;,@controller.instance_variable_get(&amp;#8221;@data&amp;#8221;))
+    dump_vars(script,&amp;#8217;Session Variables:&amp;#8217;,@controller.instance_variable_get(&amp;#8217;@session&amp;#8217;).instance_variable_get(&amp;#8221;@data&amp;#8221;))
     dump_vars(script,&amp;#8217;Flash Variables:&amp;#8217;,@controller.instance_variable_get(&amp;#8221;@flash&amp;#8221;))
     dump_vars(script,&amp;#8217;Assigned Template Variables:&amp;#8217;,@controller.assigns)
     script &amp;lt;&amp;lt; add(&amp;#8216;&lt;/table&gt;&amp;#8216;)&lt;/p&gt;</description>
      <pubDate>Sat, 01 Apr 2006 06:08:33 +1100</pubDate>
      <guid isPermaLink="false">urn:uuid:b595819b-8ead-4d77-b8de-2099479f5f14</guid>
      <link>http://www.realityforge.org/articles/2006/03/20/rails-plugin-to-help-debug-views#comment-43</link>
    </item>
    <item>
      <title>"Rails Plugin to Help Debug Views" by Violet</title>
      <description>&lt;p&gt;Thanks for pointing this out. I was not aware of this.&lt;/p&gt;</description>
      <pubDate>Mon, 20 Mar 2006 12:56:46 +1100</pubDate>
      <guid isPermaLink="false">urn:uuid:b3656565-a4b9-4586-b9a6-f413e79a393a</guid>
      <link>http://www.realityforge.org/articles/2006/03/20/rails-plugin-to-help-debug-views#comment-41</link>
    </item>
  </channel>
</rss>
