public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Improve documentation.


git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9093 
5ecf4fe2-1ee6-0310-87b1-e25e094e27de
lifo (author)
Wed Mar 26 05:27:52 -0700 2008
commit  ca9413674ea70dc67ab517734af2e40dac21beef
tree    86cbf305a2b1b4688a5b6f7cfbce8a9aa505c5f7
parent  5c47ceb30b940a8cd8eb681a898895bce46f79dd
...
1
2
 
 
3
4
5
...
1
2
3
4
5
6
7
0
@@ -1,5 +1,7 @@
0
 *SVN*
0
 
0
+* Improve documentation. [Radar, Jan De Poorter, chuyeow, xaviershay, danger, miloops, Xavier Noria, Sunny Ripert]
0
+
0
 * Fixed that FormHelper#radio_button would produce invalid ids #11298 [harlancrystal]
0
 
0
 * Added :confirm option to submit_tag #11415 [miloops]
...
227
228
229
 
 
 
 
 
 
 
230
231
232
...
227
228
229
230
231
232
233
234
235
236
237
238
239
0
@@ -227,6 +227,13 @@ module ActionController
0
     #
0
     # <% form_for :message, @message, :url => message_path(@message), :html => {:method => :put} do |f| %>
0
     #
0
+ # or
0
+ #
0
+ # <% form_for @message do |f| %>
0
+ #
0
+ # which takes into account whether <tt>@message</tt> is a new record or not and generates the
0
+ # path and method accordingly.
0
+ #
0
     # The #resources method accepts the following options to customize the resulting routes:
0
     # * <tt>:collection</tt> - add named routes for other actions that operate on the collection.
0
     # Takes a hash of <tt>#{action} => #{method}</tt>, where method is <tt>:get</tt>/<tt>:post</tt>/<tt>:put</tt>/<tt>:delete</tt>
...
49
50
51
52
 
53
54
55
...
49
50
51
 
52
53
54
55
0
@@ -49,7 +49,7 @@ module ActionView
0
       # * <tt>:url</tt>: The URL for this feed. Defaults to the current URL.
0
       # * <tt>:schema_date</tt>: The date at which the tag scheme for the feed was first used. A good default is the year you
0
       # created the feed. See http://feedvalidator.org/docs/error/InvalidTAG.html for more information. If not specified,
0
- # 2005 is used (as a "I don't care"-value).
0
+ # 2005 is used (as an "I don't care" value).
0
       #
0
       # Other namespaces can be added to the root element:
0
       #
...
76
77
78
 
79
80
81
...
85
86
87
88
 
 
89
90
91
...
405
406
407
408
 
409
410
411
...
413
414
415
416
417
 
 
418
419
420
...
430
431
432
433
434
 
 
435
436
437
438
439
 
 
440
441
442
...
76
77
78
79
80
81
82
...
86
87
88
 
89
90
91
92
93
...
407
408
409
 
410
411
412
413
...
415
416
417
 
 
418
419
420
421
422
...
432
433
434
 
 
435
436
437
438
439
 
 
440
441
442
443
444
0
@@ -76,6 +76,7 @@ module ActionView
0
       # values for the fields.
0
       #
0
       # <% form_for :person, @person, :url => { :action => "update" } do |f| %>
0
+ # <%= f.error_messages %>
0
       # First name: <%= f.text_field :first_name %>
0
       # Last name : <%= f.text_field :last_name %>
0
       # Biography : <%= f.text_area :biography %>
0
@@ -85,7 +86,8 @@ module ActionView
0
       # Worth noting is that the form_for tag is called in a ERb evaluation block, not an ERb output block. So that's <tt><% %></tt>,
0
       # not <tt><%= %></tt>. Also worth noting is that form_for yields a <tt>form_builder</tt> object, in this example as <tt>f</tt>, which emulates
0
       # the API for the stand-alone FormHelper methods, but without the object name. So instead of <tt>text_field :person, :name</tt>,
0
- # you get away with <tt>f.text_field :name</tt>.
0
+ # you get away with <tt>f.text_field :name</tt>. Notice that you can even do <tt><%= f.error_messages %></tt> to display the
0
+ # error messsages of the model object in question.
0
       #
0
       # Even further, the form_for method allows you to more easily escape the instance variable convention. So while the stand-alone
0
       # approach would require <tt>text_field :person, :name, :object => person</tt>
0
@@ -405,7 +407,7 @@ module ActionView
0
       # ==== Examples
0
       # # Let's say that @post.validated? is 1:
0
       # check_box("post", "validated")
0
- # # => <input type="checkbox" id="post_validate" name="post[validated]" value="1" checked="checked" />
0
+ # # => <input type="checkbox" id="post_validated" name="post[validated]" value="1" />
0
       # # <input name="post[validated]" type="hidden" value="0" />
0
       #
0
       # # Let's say that @puppy.gooddog is "no":
0
@@ -413,8 +415,8 @@ module ActionView
0
       # # => <input type="checkbox" id="puppy_gooddog" name="puppy[gooddog]" value="yes" />
0
       # # <input name="puppy[gooddog]" type="hidden" value="no" />
0
       #
0
- # check_box("eula", "accepted", {}, "yes", "no", :class => 'eula_check')
0
- # # => <input type="checkbox" id="eula_accepted" name="eula[accepted]" value="no" />
0
+ # check_box("eula", "accepted", { :class => 'eula_check' }, "yes", "no")
0
+ # # => <input type="checkbox" class="eula_check" id="eula_accepted" name="eula[accepted]" value="yes" />
0
       # # <input name="eula[accepted]" type="hidden" value="no" />
0
       #
0
       def check_box(object_name, method, options = {}, checked_value = "1", unchecked_value = "0")
0
@@ -430,13 +432,13 @@ module ActionView
0
       # # Let's say that @post.category returns "rails":
0
       # radio_button("post", "category", "rails")
0
       # radio_button("post", "category", "java")
0
- # # => <input type="radio" id="post_category" name="post[category]" value="rails" checked="checked" />
0
- # # <input type="radio" id="post_category" name="post[category]" value="java" />
0
+ # # => <input type="radio" id="post_category_rails" name="post[category]" value="rails" checked="checked" />
0
+ # # <input type="radio" id="post_category_java" name="post[category]" value="java" />
0
       #
0
       # radio_button("user", "receive_newsletter", "yes")
0
       # radio_button("user", "receive_newsletter", "no")
0
- # # => <input type="radio" id="user_receive_newsletter" name="user[receive_newsletter]" value="yes" />
0
- # # <input type="radio" id="user_receive_newsletter" name="user[receive_newsletter]" value="no" checked="checked" />
0
+ # # => <input type="radio" id="user_receive_newsletter_yes" name="user[receive_newsletter]" value="yes" />
0
+ # # <input type="radio" id="user_receive_newsletter_no" name="user[receive_newsletter]" value="no" checked="checked" />
0
       def radio_button(object_name, method, tag_value, options = {})
0
         InstanceTag.new(object_name, method, self, nil, options.delete(:object)).to_radio_button_tag(tag_value, options)
0
       end
...
1
2
 
 
3
4
5
...
1
2
3
4
5
6
7
0
@@ -1,5 +1,7 @@
0
 *SVN*
0
 
0
+* Improve documentation. [Radar, Jan De Poorter, chuyeow, xaviershay, danger, miloops, Xavier Noria, Sunny Ripert]
0
+
0
 * Fixed that ActiveRecord#Base.find_or_create/initialize would not honor attr_protected/accessible when used with a hash #11422 [miloops]
0
 
0
 * Added ActiveRecord#Base.all/first/last as aliases for find(:all/:first/:last) #11413 [nkallen, thechrisoshow]
...
176
177
178
179
180
181
182
183
 
 
 
 
 
184
185
186
...
176
177
178
 
 
 
 
 
179
180
181
182
183
184
185
186
0
@@ -176,11 +176,11 @@ end
0
 # Some times you don't care about the content of the fixtures as much as you care about the volume. In these cases, you can
0
 # mix ERb in with your YAML or CSV fixtures to create a bunch of fixtures for load testing, like:
0
 #
0
-# <% for i in 1..1000 %>
0
-# fix_<%= i %>:
0
-# id: <%= i %>
0
-# name: guy_<%= 1 %>
0
-# <% end %>
0
+# <% for i in 1..1000 %>
0
+# fix_<%= i %>:
0
+# id: <%= i %>
0
+# name: guy_<%= 1 %>
0
+# <% end %>
0
 #
0
 # This will create 1000 very simple YAML fixtures.
0
 #
...
91
92
93
94
 
 
 
95
96
 
97
 
98
99
100
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
102
103
...
91
92
93
 
94
95
96
97
 
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
0
@@ -91,13 +91,30 @@ module ActiveRecord
0
   #
0
   # The Rails package has several tools to help create and apply migrations.
0
   #
0
- # To generate a new migration, use <tt>script/generate migration MyNewMigration</tt>
0
+ # To generate a new migration, you can use
0
+ # script/generate migration MyNewMigration
0
+ #
0
   # where MyNewMigration is the name of your migration. The generator will
0
- # create a file <tt>nnn_my_new_migration.rb</tt> in the <tt>db/migrate/</tt>
0
+ # create an empty migration file <tt>nnn_my_new_migration.rb</tt> in the <tt>db/migrate/</tt>
0
   # directory where <tt>nnn</tt> is the next largest migration number.
0
+ #
0
   # You may then edit the <tt>self.up</tt> and <tt>self.down</tt> methods of
0
   # MyNewMigration.
0
   #
0
+ # There is a special syntactic shortcut to generate migrations that add fields to a table.
0
+ # script/generate migration add_fieldname_to_tablename fieldname:string
0
+ #
0
+ # This will generate the file <tt>nnn_add_fieldname_to_tablename</tt>, which will look like this:
0
+ # class AddFieldnameToTablename < ActiveRecord::Migration
0
+ # def self.up
0
+ # add_column :tablenames, :fieldname, :string
0
+ # end
0
+ #
0
+ # def self.down
0
+ # remove_column :tablenames, :fieldname
0
+ # end
0
+ # end
0
+ #
0
   # To run migrations against the currently configured database, use
0
   # <tt>rake db:migrate</tt>. This will update the database by running all of the
0
   # pending migrations, creating the <tt>schema_info</tt> table if missing.
...
8
9
10
11
12
13
 
 
14
15
16
17
18
19
20
 
21
22
23
24
 
25
26
27
28
29
30
31
32
 
 
 
33
34
35
36
37
38
39
40
41
 
 
 
 
42
43
44
...
46
47
48
49
50
51
52
53
54
55
 
 
 
 
 
 
56
57
58
...
8
9
10
 
 
 
11
12
13
14
15
16
17
 
 
18
19
20
 
 
21
22
23
24
25
 
 
 
 
26
27
28
29
30
31
32
 
 
 
 
 
33
34
35
36
37
38
39
...
41
42
43
 
 
 
 
 
 
 
44
45
46
47
48
49
50
51
52
0
@@ -8,37 +8,32 @@ module ActiveRecord #:nodoc:
0
     #
0
     # konata = User.find(1)
0
     # konata.to_json
0
- #
0
- # {"id": 1, "name": "Konata Izumi", "age": 16,
0
- # "created_at": "2006/08/01", "awesome": true}
0
+ # # => {"id": 1, "name": "Konata Izumi", "age": 16,
0
+ # "created_at": "2006/08/01", "awesome": true}
0
     #
0
     # The :only and :except options can be used to limit the attributes
0
     # included, and work similar to the #attributes method. For example:
0
     #
0
     # konata.to_json(:only => [ :id, :name ])
0
- #
0
- # {"id": 1, "name": "Konata Izumi"}
0
+ # # => {"id": 1, "name": "Konata Izumi"}
0
     #
0
     # konata.to_json(:except => [ :id, :created_at, :age ])
0
- #
0
- # {"name": "Konata Izumi", "awesome": true}
0
+ # # => {"name": "Konata Izumi", "awesome": true}
0
     #
0
     # To include any methods on the model, use :methods.
0
     #
0
     # konata.to_json(:methods => :permalink)
0
- #
0
- # {"id": 1, "name": "Konata Izumi", "age": 16,
0
- # "created_at": "2006/08/01", "awesome": true,
0
- # "permalink": "1-konata-izumi"}
0
+ # # => {"id": 1, "name": "Konata Izumi", "age": 16,
0
+ # "created_at": "2006/08/01", "awesome": true,
0
+ # "permalink": "1-konata-izumi"}
0
     #
0
     # To include associations, use :include.
0
     #
0
     # konata.to_json(:include => :posts)
0
- #
0
- # {"id": 1, "name": "Konata Izumi", "age": 16,
0
- # "created_at": "2006/08/01", "awesome": true,
0
- # "posts": [{"id": 1, "author_id": 1, "title": "Welcome to the weblog"},
0
- # {"id": 2, author_id: 1, "title": "So I was thinking"}]}
0
+ # # => {"id": 1, "name": "Konata Izumi", "age": 16,
0
+ # "created_at": "2006/08/01", "awesome": true,
0
+ # "posts": [{"id": 1, "author_id": 1, "title": "Welcome to the weblog"},
0
+ # {"id": 2, author_id: 1, "title": "So I was thinking"}]}
0
     #
0
     # 2nd level and higher order associations work as well:
0
     #
0
@@ -46,13 +41,12 @@ module ActiveRecord #:nodoc:
0
     # :include => { :comments => {
0
     # :only => :body } },
0
     # :only => :title } })
0
- #
0
- # {"id": 1, "name": "Konata Izumi", "age": 16,
0
- # "created_at": "2006/08/01", "awesome": true,
0
- # "posts": [{"comments": [{"body": "1st post!"}, {"body": "Second!"}],
0
- # "title": "Welcome to the weblog"},
0
- # {"comments": [{"body": "Don't think too hard"}],
0
- # "title": "So I was thinking"}]}
0
+ # # => {"id": 1, "name": "Konata Izumi", "age": 16,
0
+ # "created_at": "2006/08/01", "awesome": true,
0
+ # "posts": [{"comments": [{"body": "1st post!"}, {"body": "Second!"}],
0
+ # "title": "Welcome to the weblog"},
0
+ # {"comments": [{"body": "Don't think too hard"}],
0
+ # "title": "So I was thinking"}]}
0
     def to_json(options = {})
0
       JsonSerializer.new(self, options).to_s
0
     end
...
1
2
3
4
5
 
 
 
6
7
8
 
9
10
11
...
23
24
25
26
 
27
28
29
 
30
31
32
...
68
69
70
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
72
73
...
78
79
80
81
 
82
83
84
...
90
91
92
93
 
94
95
96
...
108
109
110
111
 
112
113
114
...
155
156
157
158
159
160
161
162
163
164
165
166
167
...
251
252
253
254
 
255
256
257
...
1
2
 
 
 
3
4
5
6
7
 
8
9
10
11
...
23
24
25
 
26
27
28
 
29
30
31
32
...
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
...
108
109
110
 
111
112
113
114
...
120
121
122
 
123
124
125
126
...
138
139
140
 
141
142
143
144
...
185
186
187
 
 
 
 
 
 
 
188
189
190
...
274
275
276
 
277
278
279
280
0
@@ -1,11 +1,11 @@
0
 module ActiveRecord #:nodoc:
0
   module Serialization
0
- # Builds an XML document to represent the model. Some configuration is
0
- # available through +options+, however more complicated cases should
0
- # override ActiveRecord's to_xml.
0
+ # Builds an XML document to represent the model. Some configuration is
0
+ # available through +options+. However more complicated cases should
0
+ # override ActiveRecord's to_xml method.
0
     #
0
     # By default the generated XML document will include the processing
0
- # instruction and all object's attributes. For example:
0
+ # instruction and all the object's attributes. For example:
0
     #
0
     # <?xml version="1.0" encoding="UTF-8"?>
0
     # <topic>
0
@@ -23,10 +23,10 @@ module ActiveRecord #:nodoc:
0
     # </topic>
0
     #
0
     # This behavior can be controlled with :only, :except,
0
- # :skip_instruct, :skip_types and :dasherize. The :only and
0
+ # :skip_instruct, :skip_types and :dasherize. The :only and
0
     # :except options are the same as for the #attributes method.
0
     # The default is to dasherize all column names, to disable this,
0
- # set :dasherize to false. To not have the column type included
0
+ # set :dasherize to false. To not have the column type included
0
     # in the XML output, set :skip_types to true.
0
     #
0
     # For instance:
0
@@ -68,6 +68,36 @@ module ActiveRecord #:nodoc:
0
     # </account>
0
     # </firm>
0
     #
0
+ # To include deeper levels of associations pass a hash like this:
0
+ #
0
+ # firm.to_xml :include => {:account => {}, :clients => {:include => :address}}
0
+ # <?xml version="1.0" encoding="UTF-8"?>
0
+ # <firm>
0
+ # <id type="integer">1</id>
0
+ # <rating type="integer">1</rating>
0
+ # <name>37signals</name>
0
+ # <clients type="array">
0
+ # <client>
0
+ # <rating type="integer">1</rating>
0
+ # <name>Summit</name>
0
+ # <address>
0
+ # ...
0
+ # </address>
0
+ # </client>
0
+ # <client>
0
+ # <rating type="integer">1</rating>
0
+ # <name>Microsoft</name>
0
+ # <address>
0
+ # ...
0
+ # </address>
0
+ # </client>
0
+ # </clients>
0
+ # <account>
0
+ # <id type="integer">1</id>
0
+ # <credit-limit type="integer">50</credit-limit>
0
+ # </account>
0
+ # </firm>
0
+ #
0
     # To include any methods on the object(s) being called use :methods
0
     #
0
     # firm.to_xml :methods => [ :calculated_earnings, :real_earnings ]
0
@@ -78,7 +108,7 @@ module ActiveRecord #:nodoc:
0
     # <real-earnings>5</real-earnings>
0
     # </firm>
0
     #
0
- # To call any Proc's on the object(s) use :procs. The Proc's
0
+ # To call any Procs on the object(s) use :procs. The Procs
0
     # are passed a modified version of the options hash that was
0
     # given to #to_xml.
0
     #
0
@@ -90,7 +120,7 @@ module ActiveRecord #:nodoc:
0
     # <abc>def</abc>
0
     # </firm>
0
     #
0
- # Alternatively, you can also just yield the builder object as part of the to_xml call:
0
+ # Alternatively, you can yield the builder object as part of the to_xml call:
0
     #
0
     # firm.to_xml do |xml|
0
     # xml.creator do
0
@@ -108,7 +138,7 @@ module ActiveRecord #:nodoc:
0
     # </firm>
0
     #
0
     # You can override the to_xml method in your ActiveRecord::Base
0
- # subclasses if you need to. The general form of doing this is
0
+ # subclasses if you need to. The general form of doing this is:
0
     #
0
     # class IHaveMyOwnXML < ActiveRecord::Base
0
     # def to_xml(options = {})
0
@@ -155,13 +185,6 @@ module ActiveRecord #:nodoc:
0
       !options.has_key?(:dasherize) || options[:dasherize]
0
     end
0
 
0
-
0
- # To replicate the behavior in ActiveRecord#attributes,
0
- # :except takes precedence over :only. If :only is not set
0
- # for a N level model but is set for the N+1 level models,
0
- # then because :except is set to a default value, the second
0
- # level model can have both :except and :only set. So if
0
- # :only is set, always delete :except.
0
     def serializable_attributes
0
       serializable_attribute_names.collect { |name| Attribute.new(name, @record) }
0
     end
0
@@ -251,7 +274,7 @@ module ActiveRecord #:nodoc:
0
 
0
       # There is a significant speed improvement if the value
0
       # does not need to be escaped, as #tag! escapes all values
0
- # to ensure that valid XML is generated. For known binary
0
+ # to ensure that valid XML is generated. For known binary
0
       # values, it is at least an order of magnitude faster to
0
       # Base64 encode binary values and directly put them in the
0
       # output XML than to pass the original value or the Base64
...
5
6
7
8
 
9
10
11
...
5
6
7
 
8
9
10
11
0
@@ -5,7 +5,7 @@ module ActiveRecord
0
   # Timestamping can be turned off by setting
0
   # <tt>ActiveRecord::Base.record_timestamps = false</tt>
0
   #
0
- # Timestamps are in the local timezone by default but can use UTC by setting
0
+ # Timestamps are in the local timezone by default but you can use UTC by setting
0
   # <tt>ActiveRecord::Base.default_timezone = :utc</tt>
0
   module Timestamp
0
     def self.included(base) #:nodoc:
...
1
2
 
 
3
4
5
...
1
2
3
4
5
6
7
0
@@ -1,5 +1,7 @@
0
 *SVN*
0
 
0
+* Improve documentation. [Radar, Jan De Poorter, chuyeow, xaviershay, danger, miloops, Xavier Noria, Sunny Ripert]
0
+
0
 * Use HEAD instead of GET in exists? [bscofield]
0
 
0
 * Fix small documentation typo. Closes #10670 [l.guidi]
...
1
2
 
 
3
4
5
...
1
2
3
4
5
6
7
0
@@ -1,5 +1,7 @@
0
 *SVN*
0
 
0
+* Improve documentation. [Radar, Jan De Poorter, chuyeow, xaviershay, danger, miloops, Xavier Noria, Sunny Ripert]
0
+
0
 * Ensure that TimeWithZone#to_yaml works when passed a YAML::Emitter. [rick]
0
 
0
 * Ensure correct TimeWithZone#to_date [Geoff Buesing]
...
1
2
3
 
 
 
 
 
 
 
 
4
5
6
...
 
 
 
1
2
3
4
5
6
7
8
9
10
11
0
@@ -1,6 +1,11 @@
0
-# Ruby 1.9 introduces BasicObject which differs slighly from Builder's BlankSlate
0
-# that had been used so far ActiveSupport::BasicObject provides a barebones object with
0
-# the same method on both versions.
0
+# A base class with no predefined methods that tries to behave like Builder's
0
+# BlankSlate in Ruby 1.9. In Ruby pre-1.9, this is actually the
0
+# Builder::BlankSlate class.
0
+#
0
+# Ruby 1.9 introduces BasicObject which differs slightly from Builder's
0
+# BlankSlate that has been used so far. ActiveSupport::BasicObject provides a
0
+# barebones base class that emulates Builder::BlankSlate while still relying on
0
+# Ruby 1.9's BasicObject in Ruby 1.9.
0
 module ActiveSupport
0
   if RUBY_VERSION >= '1.9'
0
     class BasicObject < ::BasicObject
...
24
25
26
27
 
 
28
29
30
...
32
33
34
35
36
 
 
 
37
38
39
...
45
46
47
 
 
 
 
 
 
 
 
 
48
49
50
...
58
59
60
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
62
63
...
24
25
26
 
27
28
29
30
31
...
33
34
35
 
 
36
37
38
39
40
41
...
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
...
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
0
@@ -24,7 +24,8 @@ module ActiveSupport #:nodoc:
0
           end
0
         end
0
 
0
- # Calls to_param on all its elements and joins the result with slashes. This is used by url_for in Action Pack.
0
+ # Calls <tt>to_param</tt> on all its elements and joins the result with
0
+ # slashes. This is used by <tt>url_for</tt> in Action Pack.
0
         def to_param
0
           map(&:to_param).join '/'
0
         end
0
@@ -32,8 +33,9 @@ module ActiveSupport #:nodoc:
0
         # Converts an array into a string suitable for use as a URL query string, using the given <tt>key</tt> as the
0
         # param name.
0
         #
0
- # ==== Example:
0
- # ['Rails', 'coding'].to_query('hobbies') => "hobbies%5B%5D=Rails&hobbies%5B%5D=coding"
0
+ # Example:
0
+ #
0
+ # ['Rails', 'coding'].to_query('hobbies') # => "hobbies%5B%5D=Rails&hobbies%5B%5D=coding"
0
         def to_query(key)
0
           collect { |value| value.to_query("#{key}[]") } * '&'
0
         end
0
@@ -45,6 +47,15 @@ module ActiveSupport #:nodoc:
0
           end
0
         end
0
 
0
+ # Converts a collection of elements into a formatted string by calling
0
+ # <tt>to_s</tt> on all elements and joining them:
0
+ #
0
+ # Blog.find(:all).to_formatted_s # => "First PostSecond PostThird Post"
0
+ #
0
+ # Adding in the <tt>:db</tt> argument as the format yields a prettier
0
+ # output:
0
+ #
0
+ # Blog.find(:all).to_formatted_s(:db) # => "First Post,Second Post,Third Post"
0
         def to_formatted_s(format = :default)
0
           case format
0
             when :db
0
@@ -58,6 +69,48 @@ module ActiveSupport #:nodoc:
0
           end
0
         end
0
 
0
+ # Returns a string that represents this array in XML by sending
0
+ # <tt>to_xml</tt> to each element.
0
+ #
0
+ # All elements are expected to respond to <tt>to_xml</tt>, if any of
0
+ # them does not an exception is raised.
0
+ #
0
+ # The root node reflects the class name of the first element in plural
0
+ # if all elements belong to the same type and that's not <tt>Hash</tt>.
0
+ # Otherwise the root element is "records".
0
+ #
0
+ # Root children have as node name the one of the root singularized.
0
+ #
0
+ # Example:
0
+ #
0
+ # [{:foo => 1, :bar => 2}, {:baz => 3}].to_xml
0
+ #
0
+ # <?xml version="1.0" encoding="UTF-8"?>
0
+ # <records type="array">
0
+ # <record>
0
+ # <bar type="integer">2</bar>
0
+ # <foo type="integer">1</foo>
0
+ # </record>
0
+ # <record>
0
+ # <baz type="integer">3</baz>
0
+ # </record>
0
+ # </records>
0
+ #
0
+ # The +options+ hash is passed downwards:
0
+ #
0
+ # [Message.find(:first)].to_xml(:skip_types => true)
0
+ #
0
+ # <?xml version="1.0" encoding="UTF-8"?>
0
+ # <messages>
0
+ # <message>
0
+ # <created-at>2008-03-07T09:58:18+01:00</created-at>
0
+ # <id>1</id>
0
+ # <name>1</name>
0
+ # <updated-at>2008-03-07T09:58:18+01:00</updated-at>
0
+ # <user-id>1</user-id>
0
+ # </message>
0
+ # </messages>
0
+ #
0
         def to_xml(options = {})
0
           raise "Not all elements respond to to_xml" unless all? { |e| e.respond_to? :to_xml }
0
 
...
8
9
10
11
 
12
13
14
...
45
46
47
48
 
49
50
51
...
8
9
10
 
11
12
13
14
...
45
46
47
 
48
49
50
51
0
@@ -8,7 +8,7 @@ module ActiveSupport #:nodoc:
0
         # slots with specified value (<tt>nil</tt> by default) unless it is
0
         # <tt>false</tt>.
0
         #
0
- # E.g.
0
+ # Examples:
0
         #
0
         # %w(1 2 3 4 5 6 7).in_groups_of(3) {|g| p g}
0
         # ["1", "2", "3"]
0
@@ -45,7 +45,7 @@ module ActiveSupport #:nodoc:
0
         # Divide the array into one or more subarrays based on a delimiting +value+
0
         # or the result of an optional block.
0
         #
0
- # ex.
0
+ # Examples:
0
         #
0
         # [1, 2, 3, 4, 5].split(3) # => [[1, 2], [4, 5]]
0
         # (1..10).to_a.split { |i| i % 3 == 0 } # => [[1, 2], [4, 5], [7, 8], [10]]