Can anyone please tell me what's going on here, I've copied something
pretty much directly from rails guides, but it's just not doing what
it's supposed to!
(Or I'm doing something stupid!)
rails - 3.2.2
ruby 1.9.3
my view has the following
1 - <% formations_array = @formations.map { |f| [f, f] } %>
2 - <%= formations_array.each do |f| f.to_s end%>
3 - <%= f.select(:formation_csv, options_for_select(formations_array,
2)) %>
1. the array of arrays is created from the @formations
2. prints this array of arrays [["4-3-3", "4-3-3"], ["5-3-2", "5-3-2"],
["4-4-2", "4-4-2"]]
(as I expect)
3. creates the select box, and hard coded asks for index 2 to be
currently selected, as on rails docs here : <%=
options_for_select([['Lisbon', 1], ['Madrid', 2], ...], 2) %>
However when I look at the page, the wrong selection is selected, always
index 0, not index 2.
Can anyone please tell me what's going on here! Or is this a bug?
Thanks,
Michael
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.