diff options
author | JD Huntington <jedediah@trotter.local> | 2008-05-28 23:49:09 -0700 |
---|---|---|
committer | JD Huntington <jedediah@trotter.local> | 2008-05-28 23:49:09 -0700 |
commit | 305eb5b031b1f2489e9963368358b7e9a16c0d00 (patch) | |
tree | 8a7ad65966f37ccb53986fceb245ea87da3fb39c | |
parent | f49f3e40e9262695ae3cef0e40cc6bfd013183a8 (diff) | |
download | rails-305eb5b031b1f2489e9963368358b7e9a16c0d00.tar.gz rails-305eb5b031b1f2489e9963368358b7e9a16c0d00.tar.bz2 rails-305eb5b031b1f2489e9963368358b7e9a16c0d00.zip |
added useful example for actionview's debug()
-rw-r--r-- | actionpack/lib/action_view/helpers/debug_helper.rb | 33 | ||||
-rw-r--r-- | actionpack/lib/action_view/helpers/form_options_helper.rb | 8 |
2 files changed, 25 insertions, 16 deletions
diff --git a/actionpack/lib/action_view/helpers/debug_helper.rb b/actionpack/lib/action_view/helpers/debug_helper.rb index 20de7e465f..ea70a697de 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 diff --git a/actionpack/lib/action_view/helpers/form_options_helper.rb b/actionpack/lib/action_view/helpers/form_options_helper.rb index e0a097e367..c0cba24be4 100644 --- a/actionpack/lib/action_view/helpers/form_options_helper.rb +++ b/actionpack/lib/action_view/helpers/form_options_helper.rb @@ -271,9 +271,11 @@ module ActionView end end - # Returns a string of option tags for pretty much any country in the world. Supply a country name as +selected+ to - # have it marked as the selected option tag. You can also supply an array of countries as +priority_countries+, so - # that they will be listed above the rest of the (long) list. + # Returns a string of option tags for most countries in the + # world (as defined in COUNTRIES). Supply a country name as + # +selected+ to have it marked as the selected option tag. You + # can also supply an array of countries as +priority_countries+, + # so that they will be listed above the rest of the (long) list. # # NOTE: Only the option tags are returned, you have to wrap this call in a regular HTML select tag. def country_options_for_select(selected = nil, priority_countries = nil) |