Skip to content

Commit ccad4b0

Browse files
committed
[ci skip] Modernize example; make it consistent with the example at the top documentation
1 parent 6faf60b commit ccad4b0

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

actionview/lib/action_view/helpers/form_options_helper.rb

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,25 +100,22 @@ module FormOptionsHelper
100100
#
101101
# There are two possible formats for the +choices+ parameter, corresponding to other helpers' output:
102102
#
103-
# * A flat collection (see +options_for_select+).
103+
# * A flat collection (see <tt>options_for_select</tt>).
104+
# * A nested collection (see <tt>grouped_options_for_select</tt>).
104105
#
105-
# * A nested collection (see +grouped_options_for_select+).
106+
# Example with <tt>@post.person_id => 2</tt>:
106107
#
107-
# For example:
108-
#
109-
# select("post", "person_id", Person.all.collect { |p| [ p.name, p.id ] }, { include_blank: true })
108+
# select :post, :person_id, Person.all.collect { |p| [ p.name, p.id ] }, { include_blank: true })
110109
#
111110
# would become:
112111
#
113112
# <select name="post[person_id]" id="post_person_id">
114113
# <option value="" label=" "></option>
115-
# <option value="1" selected="selected">David</option>
116-
# <option value="2">Eileen</option>
114+
# <option value="1">David</option>
115+
# <option value="2" selected="selected">Eileen</option>
117116
# <option value="3">Rafael</option>
118117
# </select>
119118
#
120-
# assuming the associated person has ID 1.
121-
#
122119
# This can be used to provide a default set of options in the standard way: before rendering the create form, a
123120
# new model instance is assigned the default options and bound to @model_name. Usually this model is not saved
124121
# to the database. Instead, a second model object is created when the create request is received.

0 commit comments

Comments
 (0)