DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Tatjana has posted 5 posts at DZone. View Full User Profile

Developer Info On Every Page

  • submit to reddit
        First, make a file in your /app/views/common_partials folder called ‘_developer_info.html.erb’

Into this, throw the following:
<a id="DevInShow" href="#" 
   onclick="$('DevInfo').show(); $('DevInShow').hide();">
 Show Developer Info</a>

<div id="DevInfo" 
     style="background:white;padding: 5px;
            border:10px solid red;position:absolute;

  <a href="#" 
     onclick="$('DevInfo').hide(); $('DevInShow').show();">
  Hide Developer Info</a>

    <%= params.to_yaml %>
    <%= session.to_yaml %>
  <a href="#" 
  Hide Developer Info</a>
The above code sets up a hidden div in your view with a link at the bottom right. When you click the link it makes the hidden div visible (which is absolutely positioned over the top of all your content) and gives you a link to click it away again. Neat.

Now, to make all this Rails-foo goodness work, add the following to the very bottom of your application.html.erb file, just before the </body> tag is good.
<%- if RAILS_ENV == "development" -%>
  <%= render :partial => 'common_partials/developer_info' %>
<%- end -%>