Hi all, In a template, you can do this: <%= debug @variable %> and you get a YAML dump of the variable in the browser. I can''t find a way to do that from an action. The following code results in NoMethodError (debug). That''s because debug is in ViewHelper. def action_method render_text(debug @variable) end Can this outcome be easily achieved (without creating a view)? Thanks, Gavin
Gavin Sinclair wrote:> Can this outcome be easily achieved (without creating a view)?The debug helper implements it like this: def debug(object) begin Marshal::dump(object) "<pre class=''debug_dump''>" + "#{h(object.to_yaml).gsub(" ", " ")}" + "</pre>" rescue Object => e # Object couldn''t be dumped, perhaps because of singleton methods # -- this is the fallback "<code class=''debug_dump''>#{h(object.inspect)}</code>" end end Note that it uses the h() method, which comes from ERb::Util - require ''erb'' Tim. -- Tim Bates tim-kZbwfhiKUx26c6uEtOJ/EA@public.gmane.org