diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2008-07-17 11:52:56 -0700 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2008-07-17 11:52:56 -0700 |
commit | 636e6b7138864ceb1e309939cd879e710b287f3e (patch) | |
tree | 2a36dfef02f706302a20bb5b2d428b32e9af97f0 /actionpack/lib/action_view/helpers/debug_helper.rb | |
parent | 842917dea0cfdf70f158a312cc1f77f769791d8c (diff) | |
parent | 99930d499e424f4560b371412e05d10476216ece (diff) | |
download | rails-636e6b7138864ceb1e309939cd879e710b287f3e.tar.gz rails-636e6b7138864ceb1e309939cd879e710b287f3e.tar.bz2 rails-636e6b7138864ceb1e309939cd879e710b287f3e.zip |
Merge branch 'master' into i18n-merge
Conflicts:
actionpack/lib/action_view/helpers/form_options_helper.rb
activerecord/lib/active_record/validations.rb
Diffstat (limited to 'actionpack/lib/action_view/helpers/debug_helper.rb')
-rw-r--r-- | actionpack/lib/action_view/helpers/debug_helper.rb | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/actionpack/lib/action_view/helpers/debug_helper.rb b/actionpack/lib/action_view/helpers/debug_helper.rb index 20de7e465f..90863fca08 100644 --- a/actionpack/lib/action_view/helpers/debug_helper.rb +++ b/actionpack/lib/action_view/helpers/debug_helper.rb @@ -2,21 +2,28 @@ module ActionView module Helpers # Provides a set of methods for making it easier to debug Rails objects. module DebugHelper - # Returns a <pre>-tag that has +object+ dumped by YAML. This creates a very - # readable way to inspect an object. + # Returns a YAML representation of +object+ wrapped with <pre> and </pre>. + # If the object cannot be converted to YAML using +to_yaml+, +inspect+ will be called instead. + # Useful for inspecting an object at the time of rendering. # # ==== Example - # my_hash = {'first' => 1, 'second' => 'two', 'third' => [1,2,3]} - # debug(my_hash) # - # => <pre class='debug_dump'>--- - # first: 1 - # second: two - # third: - # - 1 - # - 2 - # - 3 - # </pre> + # @user = User.new({ :username => 'testing', :password => 'xyz', :age => 42}) %> + # debug(@user) + # # => + # <pre class='debug_dump'>--- !ruby/object:User + # attributes: + # updated_at: + # username: testing + # + # age: 42 + # password: xyz + # created_at: + # attributes_cache: {} + # + # new_record: true + # </pre> + def debug(object) begin Marshal::dump(object) @@ -28,4 +35,4 @@ module ActionView end end end -end
\ No newline at end of file +end |