This project is archived and is in readonly mode.

#1348 ✓wontfix
revgum

Clarify options_from_collection_for_select example

Reported by revgum | November 8th, 2008 @ 07:08 PM | in 2.x

I'm not sure if I'm doing this correctly.. I'm using the diff from Github. Please bear with me, and let me know if I should submit this differently?

@@ -207,6 +207,11 @@ module ActionView 0

   # options_from_collection_for_select(@project.people, "id", "name")

0

   # <option value="#{person.id}">#{person.name}</option>

0

   #

0 + # Example (call, result). When specifying +selected+ using an ID be sure to pass an Integer rather than a string: 0 + # options_from_collection_for_select(@project.people, "id", "name", some_id.to_i) 0 + #

#{person.name} 0 + # #{person.name} #assume some_id was a string value of this person.id 0 + # 0
   # NOTE: Only the option tags are returned, you have to wrap this call in a regular HTML select tag.

0

   def options_from_collection_for_select(collection, value_method, text_method, selected = nil)

0

     options = collection.map do |element|

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

People watching this ticket

Attachments

Pages