I’m trying to get a select box to populate with the current option for
editing
purposes. I can populate the box, but not with the currently selected
value.
I’ve read in the api where it says to do this:
# Example with @post.person_id => 1:
# select("post", "person_id", Person.find_all.collect {|p| [
p.name,
p.id ] }, { :include_blank => true })
and
# By default, post.person_id is the selected option. Specify
:selected =>
value to use a different selection
# or :selected => nil to leave all options unselected
I have this in my view:
<%= select(“impact”, “guide_id”, Guide.find_all.collect {|p| [p.acronym,
p.id ]
}, { :include_blank => true} ) %>
I know guide_id variable is set because in the tag before it I can show:
<%= impact.guide_id %>
I’ve even tried this, which just makes the box say “Please select” upon
load:
<%= select(“impact”, “guide_id”, @guides, :id, :acronym, :selected =>
impact.guide_id) %>
I’m trying to do all this in a for loop. I’ve seen where there appears
to be
some changed made to ActionPack in regards to this feature, but it seems
to be
only if I want to set the selected value to something other than
@variable.method.
http://dev.rubyonrails.org/ticket/1125
http://dev.rubyonrails.org/ticket/2991
Any help would be greatly appreciated.