module ActionView::Helpers::DebugHelper

def debug(object)

def debug(object)
  begin
    Marshal::dump(object)
    "<pre class='debug_dump'>#{h(object.to_yaml).gsub("  ", "&nbsp; ")}</pre>".html_safe
  rescue Exception => e  # errors from Marshal or YAML
    # Object couldn't be dumped, perhaps because of singleton methods -- this is the fallback
    "<code class='debug_dump'>#{h(object.inspect)}</code>".html_safe
  end
end